0% found this document useful (0 votes)
33 views54 pages

Prac

Uploaded by

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

Prac

Uploaded by

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

JASPAL KAUR PUBLIC SCHOOL

COMPUTER SCIENCE
PRACTICAL FILE
ACADEMIC YEAR – 2024 -25

SUBMITTED BY:
NAME – Saurish Seth
CLASS – 12 A
BOARD ROLL NO. –
SUBJECT – COMPUTER SCIENCE
SUBMITTED TO: Ms. Pooja Nemani (PGT Computer)

1
INDEX

S.NO TOPIC PAGE


NO.
1. Functions 4-8
2. Text file handling 9-13
3. Binary file handling 14-18
4. CSV file handling 19-21
5. Stack 22-25
6. DBMS (SET1) 27-30
7. DBMS (SET2) 31-35
8. DBMS (SET3) 36-40
9. DBMS (SET4) 41-45
10. DBMS (SET5) 46-49
11. Python interface with 50-54
MySQL

2
FUNCTIONS

3
Q1. Write a program to have following functions:
(i) a function that takes a number as argument and calculates cube for it. The function
does not return a value .If there is no value passed to the function in function call,
the function should calculate cube of 2
(ii) A function that takes two char arguments and returns True if both the arguments
are equal otherwise False.
Test both these functions by giving appropriate function call statements.
1. (i)

Output :

4
1.(ii)

Output :

5
2.Write a program to find sum of multiple numbers using user defined function
sum().

Output :

6
3. Write a program to create function calculation() such that it can accept two
variables and calculate addition and subtraction. Also, it must return both
addition and subtraction in a single return call.

Output :

7
4. Write a program to create function func1() to accept a variable length of
arguments and print their sum.

Output :

Output:

8
TEXT FILE
HANDLING

9
1. Write a program to count a total number of lines and count the total number
of lines starting with 'A', 'B', and 'C'.

Output :

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

Output :

11
3.Remove all the lines that contain the character a' in a file and write it to another
file.

Output :

File having without ‘a’ containg sentence.

Other file having ‘a’ containing sentence.

12
4. Write a program to count total number of A/An in the text file "merge.text"
(ignore case).

Output :

13
14
BINARY FILE
HANDLING

15
1.Write a definition for function BUMPER() in PYTHON to read each object of a
binary file GIFTS.DAT, find and display details of those gifts, which have remarks as
“ON DISCOUNT”. Assume that the file GIFTS.DAT is created with the help of lists of
following type: (ID, Gift, Remarks, Price)

Output:

2. Create a binary file with name and roll number. Search for a given roll number
and display the name, if not found display appropriate message.

16
Output :

3. Create a binary file with roll number, name and marks. Input a roll number
and update the marks.

17
Output :

4. Following is the structure of each record in a data file named "PRODUCT.DAT":


{"prod_code":value, "prod_desc":value, "stock":value} The values for prod_code
and prod_desc are strings, and the value for stock is an integer. Write a function
in PYTHON to update the file with a new value of stock. The stock and the

18
product_code, whose stock is to be updated, are to be input during the execution
of the function.

Output :

19
CSV FILE
HANDLING

20
1. Write a program to perform read and write operation with .csv file.

Output :

21
2. Create a CSV file by entering user-id and password, and update the
password for given user id.

Output :

22
STACK

23
1. Vedika has created a dictionary containing names and marks as key-value pairs of
5 students. Write a program, with separate user-defined functions to perform the
following operations:

(i) Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.

Output :

(ii) Pop and display the content of the stack.

Output :

24
B) Write a program to create a Stack for storing only odd numbers out of all the
numbers entered by the user. Display the content of the Stack along with the largest
odd number in the Stack.Also display “ Stack Empty” when there are no elements in
the stack.

Output :

25
DBMS

26
SQL 1
(SET-1)

27
TABLE 1

TABLE 2

28
i) Display the mobile company,mobile name and price in descending order of their manufacturing

date.
ii) List the details of mobiles whose names starts with ‘s’.

iii) Display the mobile supplier and the quantitiy of all mobiles except ‘MB003’

iv) Display the mobile company havingthe price between 3000 and 5000

29
Find output of the following queries :
v)

vi)

vii)

viii)

30
SQL 2
(SET 2)

31
TABLE 1

TABLE 2

32
i) Display the trainer name,city and salary in descnding order of the hiredate

ii) Display the Tname and city of the trainer wo joined the institute in month of december 2001.

iii) To display the Tname,hiredate,Cname,start date from the table trainer and couuse of all those
courses whose fees is less than or equal to 10000

33
iv) To display the number of trainers from each city.

34
Find the output of the following queries :
v)

vi)

vii)

viii)

35
SQL 3
(SET 3)

36
TABLE 1

TABLE 2

37
i) To display the details of those faculty whose salary is grater than 12000

ii) To display the details of those courses whose fees is in range 15000 and 50000
(including both).

38
iii) To increase the fees of all courses by 500 of (‘System design ‘ course

iv) To display the details of those courses taught by sulekha in descending order of courses

39
Find the output of the following queries :
v)

vi)

vii)

viii)

40
SQL 4
(SET 4)

41
TABLE 1

TABLE 2

42
i) To display the details of those watches whose name ends with ‘Time’.

ii) To display the watchname and prices of those watches which have price range between 5000
and 15000

iii) To display the total quantity of unisex type of watch

iv) To display the wattchname and their total quantity sold in the first quater

43
Find the output of the following queries :

v)

vi)

44
vii)

viii) Had doubt in this question.

45
SQL 5
(SET 5)

46
TABLE 1

47
i) To display the student records from student table in alphabetical order namewise.

ii) To display class,DOB and city whose marks are between 450 and 551.

iii) Had doubt in this question


iv) To increase marks of all students by 20 who are in class XII.

48
Find the output of the folloing queries :

v)

vi)

vii)

49
PYTHON
INTERFACE
WITH MYSQL

50
1. Write a program to integrate SQL with python by importing the mysql module
and to add records of customer details

Output :

51
2. Write a program to integrate SQL with python by importing the mysql module
and to search customer ID in table “customer” and display record, if customer ID
not found display appropriate message.

Output :

52
3. Write a program to integrate SQL with python by importing the mysql module
and to update customer record of entered customer ID.

Output :

53
4. Write a program to integrate SQL with python by importing the mysql module
and to display all the records of table “customer

Output :

54

You might also like