DPS RUBY PARK, KOLKATA
CLASS XII COMPUTER SCIENCE BOARD PRACTICAL
FILE
Submission Deadline: 05 NOVEMBER, 2024
NB: If you submit any time after the deadline, you will not receive full credit points
PRACTICAL FILE FORMAT INSTRUCTIONS
⮚ Programs are to be written in the school Practical File (same as
Chemistry Practical File)
⮚ Each Program must start in a new page
⮚ Solution is to be divided into two parts – Code and Output
⮚ Output should be written on the blank side of the page
⮚ Output should be written in pencil or with a black ink ball pen.
⮚ File programs may need to display file data to support the output.
⮚ Index page details will be provided later, so do not fill it.
PROGRAMS ON LIST, STRING & DICTIONARY USING FUNCTION:
1 Write a program using a function to input a string (word). Convert it into
lowercase letters. Count and print the frequency of each alphabet present in
the string. The output should be given as:
Sample Input: Alphabets
Sample Output:
==========================
Alphabet Frequency
==========================
a 2
b 1
e 1
h 1
l 1
p 1
s 1
Page 1 of 7
2 Write a program using a function to input a list of elements and display a
list with only duplicate elements after removing the unique ones.
Output:
The original list: [10, 20, 30, 10, 40, 20, 50]
The Duplicate list: [10, 20]
3 Write a program to take input of two lists from the user and perform union
and intersection of these two lists.
Example:
Enter first list: [2,3,5,6,7,8]
Enter second list: [4,5,6,9]
Union: [2,3,4,5,6,7,8,9]
Intersection: [5,6]
4 Write a program to take input of a list from user and swap the adjacent
elements (first & second, Third & Fourth and so on)
Example:
Enter a list: [2,3,4,5,6,7,8]
Output: [3,2,5,4,7,6,8]
5 Write a program to input two dictionary and then subtract the values of two
dictionary.
Output :
The original dictionary 1: {'gfg': 6, 'is': 4, 'best': 7}
The original dictionary 2: {'gfg': 10, 'is': 6, 'best': 10}
The difference dictionary is : {'gfg': 4, 'is': 2, 'best': 3}
PROGRAMS ON TEXT FILES:
6 Write a function to open the text file ABC.txt and count the number of
words that start with ‘the’, like the, their, they, them, these etc.
7 Write a Python program to count all lines in the file ABC.txt having ‘a’ as
the last character.
Page 2 of 7
8 Write a Python program to count the number of digits in the text file
DIGIT.txt.
9 Write a function to transfer all lines starting with a vowel from ORIGIN.txt
to NEW.txt.
10 Write a Function to read data from a text file DATA.TXT, and display those
words, which are less than 4 characters.
PROGRAMS ON BINARY FILES:
11 Write a function to add (append) Employee records (Empno, name and
address, salary) onto a Binary file.
12 Write a function to Delete a Student record (Rollno, name, class, section,
mobileno, marks) in a binary file named Student.dat. Record will be deleted
based on Rollno passed as parameter to the function.
13 Write a function to Update marks of a Student record (Rollno, name,
marks)in a binary file named Student.dat. Record will be updated based on
Rollno passed as parameter to the function.
PROGRAMS ON CSV FILES:
Create a csv file patient.csv and write the following program.
Page 3 of 7
14 Write a program to display the record of those patients whose cholesterol is
more than 250 and Resting BP is less than 125 from a file the “patient.csv”.
15 Write a program to display the Blood sugar of those patients whose name
either starting with ‘O’ or ending with ‘r’ and Age is more than 70 from file
the“patient.csv”.
16 Write a program to display the content of rows in reverse order from the file
“patient.csv”.
PROGRAMS ON PYTHON-MYSQL INTERFACE:
17 Write a Program to connect with database and store record in employee
table (empno, empname, department, salary) and display entire records.
18 Write a Program to connect with database and search a record from
employee table (empno, empname, department, salary) based on empno and
display records.
19 Write a Program to connect with database and update a record from
employee table (empno, empname, department, salary) based on empno and
display records.
20 Write a Program to connect with database and delete a record from
employee table (empno, empname, department, salary) based on empno and
display records.
QUERY ON MYSQL :
21 Consider the following table Prepaid and answer the below-given questions
Page 4 of 7
Table: Prepaid
CustoID Custname Model Connection Plan
C0001 Sagar Xiomi Vodafone 399
C0002 Priya Oppo Jio 149
C0003 Milan Vivo Vodafone 699
C0004 Kaushik Redmi Airtel 250
C0005 Karthik Vivo Jio 79
Write SQL queries for the following:
A. To display customer details who are using Jio and vodafone.
B. To display unique connection from the table.
C. To display the maximum plan amount for each connection.
D. To display the count of each model type.
E. To display customer details whose names end with ‘k’.
22 Consider the following table Stock to answer the queries:
ITEMNO ITEM DCODE QTY UNITPRICE STOCKDATE
S005 Ballpen 102 100 10 2018/04/22
S003 Gel Pen 101 150 15 2018/03/18
S002 Pencil 102 125 5 2018/02/25
S006 Eraser 101 200 3 2018/01/12
S001 Sharpener 103 210 5 2018/06/11
Write SQL queries for the following:
a. Display all the items in the ascending order of stockdate.
b. Display all the items in descending orders of item names.
Page 5 of 7
c. Display average price of items for each dealer individually as per
dcode from stock whose average price is more than 5.
d. Display the sum of quantity for each dcode.
e. Display maximum price of items for each dealer individually as per
dcode from stock.
23 Create a table Club in the database Sports by using the following
constraints and execute the following queries:
Coach_Id to be set as primary key.
Check PAY should not be less than 30000. Coach name should be NOT
NULL.
Coach_Id Coach_Name Age Sports Pay
1 TARUN 35 BASKETBALL 500
2 ANIRUDDH 34 SWIMMING 600
3 ANIMESH 32 SQUASH 900
4 ANIL 35 SWIMMING 500
5 SUMIT 33 KARATE 700
A. Display the names of those coaches whose name start with the letter
“A” and ends with “H”.
B. Display the sum of Pay of the Swimming coaches
C. Display the name of the coaches and their age in descending order of
age.
D. Increase the pay of all the coaches by 10%.
E. Remove Primary key constraint from Coach_Id and add Coach_Name
as primary key.
F. Delete the records of the coaches of Swimming.
G. Add a new column Gender in the table “Club”
Page 6 of 7
24 Create a table “Product” in the database “Stock” by using the following
constraints and execute the following queries:
PID should be set as the primary key.
Check Total price should not be more than 100000.
PID PRODUCT NUMBER_OF_ITEMS TOTAL_PRICE
P01 CURTAIN 43 52200
P02 BEDSHEET 92 32700
P03 REFRIGERATOR 100 21500
COVER
P04 PILLOW PACK 20 2430
P05 WASHING 34 2210
MACHINE
COVER
a. Display the names of those products whose name ends with the letter
“R”.
b. Display those products which are available in stock less than 50.
c. Display the products and their total price in descending order of their
total price.
d. Remove Primary key constraint from PID and add product name as
primary key.
e. Increase the number of items of all the products by 10%.
f. Delete the records of those products where the total price is less than
5000.
g. Add a new column Date_of_manufacture in the table “Product”.
Page 7 of 7