0% found this document useful (0 votes)
579 views40 pages

Avi Arora Computer Science Practical File

This document contains a practical file for a computer science class covering various programming assignments completed over multiple sessions. It includes 25 questions covering topics like inputting integers and finding LCM, counting elements in a list within a range, calculating uppercase and lowercase letters in a string, reversing a string, calculating average of tuple elements, reading and processing text files, binary file operations, random number generation, CSV file operations, stack operations, SQL queries on multiple tables, and connecting Python to MySQL. For each question, the coding and output is documented.

Uploaded by

Aryan Jangpangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
579 views40 pages

Avi Arora Computer Science Practical File

This document contains a practical file for a computer science class covering various programming assignments completed over multiple sessions. It includes 25 questions covering topics like inputting integers and finding LCM, counting elements in a list within a range, calculating uppercase and lowercase letters in a string, reversing a string, calculating average of tuple elements, reading and processing text files, binary file operations, random number generation, CSV file operations, stack operations, SQL queries on multiple tables, and connecting Python to MySQL. For each question, the coding and output is documented.

Uploaded by

Aryan Jangpangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

PRACTICAL FILE

Session 2022 – 23 (Term I)


Computer Science (083)
Std XII

Guided by:
Ms. Neha Adlakha
Submitted by:
Name : Avi Arora
Class: XII – A
Board Roll no.:

1|Page
INDEX
S.NO. TOPIC DATE PAGE NO. TEACHER
SIGN.
1 WAP to input two integers and find their LCM.

2 WAP to count the number of elements in a list


within a specified range.

3 WAP that accepts a string and calculates the


number of uppercase letters and lowercase
letters using functions.

4 WAP to reverse a string using functions

5 WAP using user-defined function to calculate


and display average of all the elements in a
user-defined tuple containing numbers.

6 Read a text file by line and display each word


separated by a #.

7 Read a text file and display the number of


vowels/ consonants/ uppercase/lowercase
characters in a file

8 Remove all the lines that contain the character


‘a’ in a file and write it to another file.

9 Create a binary file with name and roll no.


search for a given roll no and display the name,
if not found display appropriate message

10 Create a binary file with roll no, name and


marks. Input a roll no and update the marks

11 Write a random number generator that


generates random numbers between 1 and
6(simulates a dice).

12 Create a CSV file by entering user-id and


password, read and search the password for
given user-id

13 WAP to store multiple integers in and from a


binary file.

14 WAP to count the number of records present in


“student.csv” file

15 Write a menu driven program to perform read


and write operations using a text file called
“student.txt” containing student roll_no, name
and address using two separate functions.

2|Page
PRACTICAL 1 :

Q1.WAP to input two integers and find their LCM.

CODING:

OUTPUT:

3|Page
PRACTICAL 2:

Q2.WAP to count the number of elements in a list within a specified range.

CODING:

OUTPUT:

4|Page
PRACTICAL 3:

Q3.WAP that accepts a string and calculates the number of uppercase letters and lowercase letters
using functions.

CODING:

OUTPUT:

5|Page
PRACTICAL 4:

Q4.WAP to reverse a string using functions

CODING:

OUTPUT:

6|Page
PRACTICAL 5:

Q5.WAP using user-defined function to calculate and display average of all the elements in a user-
defined tuple containing numbers.

CODING:

OUTPUT:

7|Page
PRACTICAL 6:

Q6.Read a text file by line and display each word separated by a #.

CODING:

O
UTPUT:

8|Page
PRACTICAL 7:

Q7.Read a text file and display the number of vowels/ consonants/ uppercase/lowercase characters
in a file

CODING:

OUTPUT:

9|Page
PRACTICAL 8:

Q8.Remove all the lines that contain the character ‘a’ in a file and write it to another file.

CODING:

10 | P a g e
OUTPUT:

11 | P a g e
Q9.Create a binary file with name and roll no. search for a given roll no and display the name, if not
found display appropriate message

CODING:

OUTPUT:

12 | P a g e
Q10.Create a binary file with roll no, name and marks. Input a roll no and update the marks

CODING:

13 | P a g e
OUTPUT:

14 | P a g e
Q11.Write a random number generator that generates random numbers between 1 and 6(simulates
a dice).

CODING:

OUTPUT:

15 | P a g e
Q12.. Create a CSV file by entering user-id and password, read and search the password for given
user-id

CODING:

OUTPUT:

16 | P a g e
Q13. WAP to store multiple integers in and from a binary file.

CODING:

OUTPUT:

17 | P a g e
Q14..WAP to count the number of records present in “student.csv” file

CODING:

OUTPUT:

18 | P a g e
Q15.Write a menu driven program to perform read and write operations using a text file called
“student.txt” containing student roll_no, name and address using two separate functions:

• student_record(filename) – entering student details

• student_readdata(filename) – display student details

• student_search(filename) – search a student on basis of roll_no

CODING:

19 | P a g e
OUTPUT:

20 | P a g e
Q16. Write a Python program to implement all basic operations of a Stack, such as adding element,
removing element and displaying the Stack elements using lists.

CODING:

OUTPUT:

21 | P a g e
Q17. WAP to display unique vowels in the given word using Stack.

22 | P a g e
Q18.Write a program to create a Stack called Employee, to perform the basic operations on Stack
using list. The list contains the two values-employee number and employee name. The program
should include the options for addition, deletion and display of employee details.

CODING:

23 | P a g e
OUTPUT:

24 | P a g e
Q19.Consider a database LOANS with the following table:

TABLE: LOANS

Answer the following questions.

(i)Display the sum of all Loan Amounts whose Interest rate is greater than 10.

(ii) Display the Maximum Interest from Loans table.

(iii) Display the count of all loan holders whose name ends with 'Sharma'.

(iv) Display the count of all loan holders whose Interest rate is Null.

(v) Display the Interest-wise details of Loan Account Holders.

(vi) Display the Interest-wise details of Loan Account Holders with at least 10 instalments remaining.

ANSWERS:

(i)

(ii)

(iii)

25 | P a g e
(iv)

(v)

(vi)

Q20.Consider the following two tables: Stationery and Consumer.

26 | P a g e
TABLE: STATIONERY

Table: Consumer

Write SQL statements for the queries (i) to (iv) and output for (v) and (vi):

(i) To display details of all the Stationery Items in the Stationery table in descending order
ofStockDate.

(ii) To display details of that Stationery item whose Company is XYZ and price is below 10.

(iii) To display ConsumerName, Address from the table Consumer and Company and Price from

Stationery table, with their corresponding S_ID.

(iv) To increase the price of all the stationery items in Stationery table by * 2.

(v) SELECT COUNT (DISTINCT Address) FROM Consumer;

(vi) SELECT StationeryName, price* 3 FROM Stationery

Answers:

27 | P a g e
(i)

(ii)

(iii)

(iv)

(v)

28 | P a g e
(vi)

Q21.Consider the following two tables: SCHOOL and ADMIN.

29 | P a g e
TABLE: SCHOOL

TABLE: ADMIN

1. Select Designation, Count (*) From Admin Group By Designation Having Count (*) <2;

2. SELECT max (EXPERIENCE) FROM SCHOOL;

3. SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY TEACHER;

4. SELECT COUNT(*), GENDER FROM ADMIN GROUP BY GENDER;

ANSWERS:

30 | P a g e
(1)

(2)

(3)

(4)

31 | P a g e
Q22.Write SQL commands for (1) to (4) and output (5) to (8) based on the
following table COMPANY and CUSTOMER.

TABLE: COMPANY

TABLE: CUSTOMER

1. To display those company name which are having prize less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the prize by 1000 for those customers whose name starts
with S?
4. To add one more column totalprice with decimal (10,2) to the table
customer.

32 | P a g e
Answers:
(i)
(ii)

(iii)

(iv)

33 | P a g e
Q23.Consider the tables and write queries for the following:
TABLE: ITEM

TABLE: BRAND

Write MySQL queries for the following:


(i) To display Item_Code, Item_Name and corresponding
Brand_Name of those items, whose Price is between 20000
and 40000(both values included).
(ii) To display Item_Code, Price, and Brand_Name of the item
which has Item_Name as ‘Computer’.
(iii) To increase the priced of all the items by 10%.

34 | P a g e
Answers:
(i)

(ii)

(iii)

35 | P a g e
Q24.WAP to show MySQL connectivity with Python.

CODING:

OUTPUT:

36 | P a g e
Q25.Perform all operations with reference to table “LOANS” through MySQL-Python connectivity.

CODING:

37 | P a g e
38 | P a g e
OUTPUT:

39 | P a g e
40 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy