BAL BHAVAN PUBLIC
SCHOOL
COMPUTER SCIENCE
Practical File
Session: 2025-26
Submitted by: Section - XII -
Name - Kushagra A Roll
Chauhan Class and Number -
Submitted to:
Ms. Harpreet Kaur Verma
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Write a program to check a number
whether it is palindrome or not.
1
Write a program to display ASCII code
of a word ‘Help’ and vice versa.
2
Write a python program to sum the
sequence given below. Take the input n
3 from the user. 1+1/1!+1/2!+1/3!+ +1/n!
⋯
Write a python program to calculate the
nth term of Fibonacci Series.
4
Write a python program to search any
word in the given string/ sentence.
5
Write a python code to handle the zero
division error, Value error, type error.
Display the output of all the error cases
and without error case.
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Consider a dictionary containing names
and marks as key : value pair. Write
menu driven program that defines and
call the following functions:
a. Push the keys of the dictionary into
stack where corresponding value
(marks) is greater than 70.
7 b. Pop all the elements from stack and
display appropriate message when
stack is empty.
c. Isempty() that return true if stack is
empty else return false. Call this
function to check the stack is empty or
not.
d. Show the peek element of stack and
display appropriate message if stack is
empty.
Write a program to read a text file line
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Write a program to count the number of
vowels present in a text file. Also
display the content of text file first and
9
then display the desired output.
Write a program to count number of
words in a file. Also display the content
10 of text file first and then display the
desired output.
Write a program to count the number of
times the occurrence of 'is' word in a
11
text file. Also display the content of text
file first and then display the desired
output.
Write a program to write those lines
which have the character 'p' from one
text file to another text file. Also display
the content of text first file first and
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Write a menu-driven program
implementing user-defined functions to
perform different functions on csv file
student such as: [Rno, Name, Marks]:
13 a. Write a single record on to csv file
b. Display the content of file
c. Display the name of the student
score 75 above
A binary file [Link] has the following
structure: [TNO, TNMAE, TTYPE, ARR,
DEP,
DEP_date] (Train Number, Train Name ,
Train Type, Arrival Place, Departure
From, Departure_Date) Write menu
driven program that defines and call the
following functions:
a. Write a record on to binary file
b. Search a train where destination is
passed as parameter
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Surya is a manager working in a
recruitment agency. He needs to
manage the records of various
candidates. For this, he wants the
following information of each candidate
to be stored: - Candidate_ID – integer -
Candidate_Name – string - Designation
– string - Experience – float You, as a
programmer of the company, have
been assigned to do this job for Surya.
Write menu driven program that
defines and call the following functions:
a. Write a function to input the data of a
candidate and append it in a binary file.
b. Write a function to update the data
of candidates whose experience is more
than 10 years and change their
designation to "Senior Manager".
c. Write a function to read the data
from the binary file and display the
INDEX
Seri Teacher
Program ’s
al
no. Signatu
A csv file “P_record.csv” contains the
records of patients in a hospital. Each
record of the file contains the following
data: Name of a patient Disease
Number of days patient is admitted
Amount For example, as ample record
of the file may be: [“Gunjan”,
“Jaundice”, 4, 15000] Write menu
driven program that defines and call
the following functions:
a. Write a function to add data.
b. Write the function details of the ‘
read_data() Cancer ’ patients.
c. Write a function count_rec() which
reads all the data from the file and
displays the which counts and returns
INDEX
Seri Teacher
Program ’s
al
no. Signatu
Keshav is working in an hospital. To
keep the expenses of a patient, he has
created CSV file names ‘[Link]’
which store the details of each
[Link], PaitentName,
RoomCharges, Medicine_Exp,
LabCharges. Write menu driven
program that defines and call the
17
following functions:
a. Accept()-to accept a paitent record
from the user and add it to the file
[Link].
b. Calculatebill()- to calculate total bill
and return the total bill that is sum of
RoomCharges, Medicine_Exp,
LabCharges whose patientid is passed
as parameter.
Write menu driven program that
defines and call the following functions:
a. Add records in the table
b. Update the salary of trainer whose
INDEX
Seri Teacher
Program ’s
al
no. Signatu
For the given tables Loan_Accounts.
Write MY SQL commands and give
19 outputs for SQL queries.
In a database create the suitable tables
with mentioned constraints in the
question.
PROGRAMS
PROGRAM 1: Write a program to check a number
whether it is palindrome or not.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 2: Write a program to display ASCII code of
a word ‘Help’ and vice versa.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 3: Write a python program to sum the
sequence given below. Take the input n from the user.
1+1/1!+1/2!+1/3!+
⋯
+1/n!
CODING:
OUTPUT:
PROGRAMS
PROGRAM 4: Write a python program to calculate
the nth term of Fibonacci Series.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 5: Write a python program to search any
word in the given string/ sentence.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 6: Write a python code to handle the
zero division error, Value error, type error. Display the
output of all the error cases and without error case.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 7: Consider a dictionary containing
names and marks as key:value pair. Write menu
driven program that defines and call the following
functions:
a. Push the keys of the dictionaryinto stack
where corresponding value (marks) is greater than
70.
b. Pop all the elements from stack and display
appropriate message when stack is empty
c. Isempty() that return true if stack is empty else
return false. Call this function to check the stack is
empty or not.
d. Show the peek element of stack and display
appropriate message if stack is empty.
CODING:
PROGRAMS
PROGRAMS
CODING(continued):
OUTPUT:
PROGRAMS
OUTPUT(continued):
PROGRAMS
PROGRAM 8: Write a program to read a text file
line by line and display each word separated by '#'.
Also display the content of text file first and then
display the desired output.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 9: Write a program to count the number
of vowels present in a text file. Also display the
content of text file first and then display the desired
output.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 10: Write a program to count number of
words in a file. Also display the content of text file
first and then display the desired output.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 11: Write a program to count the
number of times the occurrence of 'is' word in a text
file. Also display the content of text file first and then
display the desired output.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 12: Write a program to write those lines
which have the character 'p' from one text file to
another text file. Also display the content of text first
file first and then display the content of another file.
CODING:
OUTPUT:
PROGRAMS
PROGRAM 13: Write a menu-driven program
implementing userdefined functions to perform
different functions on csv file student such as: [Rno,
Name, Marks]
a. Write a single record on to csv file
b. Display the content of file
c. Display the name of the student score 75 above.
CODING:
PROGRAMS
PROGRAMS
CODING(continued):
OUTPUT:
PROGRAMS
OUTPUT(continued):
PROGRAMS
PROGRAM 14: A binary file [Link] has the
following structure: [TNO,TNMAE,TTYPE, ARR, DEP,
DEP_date] (Train Number, Train Name , Train Type,
Arrival Place, Departure From, Departure_Date) Write
menu driven program that defines and call the
following functions:
a. Write a record on to binary file
b. Search a train where destination is passed as
parameter
c. Update the Departure date of the train whose Train
number is passed as parameter.
CODING:
PROGRAMS
PROGRAMS
CODING(continued):
PROGRAMS
OUTPUT:
PROGRAMS
PROGRAM 15: Surya is a manager working in a
recruitment agency. He needs to manage the
records of various candidates. For this, he wants the
following information of each candidate to be stored:
- Candidate_ID – integer - Candidate_Name – string -
Designation – string - Experience – float You, as a
programmer of the company, have been assigned to
do this job for Surya. Write menu driven program
that defines and call the following functions:
a. Write a function to input the data of a candidate
and append it in a binary file.
b. Write a function to update the data of candidates
whose experience is more than 10 years and change
their designation to "Senior Manager".
c. Write a function to read the data from the binary
file and display the data of all those candidates who
are not "Senior Manager".
PROGRAMS
CODING:
PROGRAMS
OUTPUT:
PROGRAMS
OUTPUT(continued):
PROGRAMS
PROGRAM 16: A csv file “P_record.csv” contains the
records of patients in a hospital. Each record of the
file contains the following data: • Name of a patient •
Disease • Number of days patient is admitted • Amount
For example, as ample record of the file may be:
[“Gunjan”, “Jaundice”, 4, 15000] Write menu driven
program that defines and call the following functions:
a. Write a function to add data.
b. Write the function details of the ‘ read_data() Cancer
’ patients.
c. Write a function count_rec() which reads all the
data from the file and displays the which counts and
returns the number of records in the file.
PROGRAMS
CODING:
PROGRAMS
OUTPUT:
PROGRAMS
PROGRAM 17: Keshav is working in an hospital. To
keep the expenses of a patient, he has created CSV
file names ‘[Link]’ which store the details of
each [Link], PatientName, RoomCharges,
Medicine_Exp, LabCharges. Write menu driven
program that defines and call the following functions:
a. Accept()-to accept a paitent record from the user
and add it to the file [Link]
b. Calculatebill()- to calculate total bill and return the
total bill that is sum of RoomCharges, Medicine_Exp,
LabCharges whose patientid is passed as parameter.
CODING:
PROGRAMS
CODING(continued):
OUTPUT:
PROGRAMS
OUTPUT (continued):
PROGRAMS
PROGRAM 18: Consider the following trainer table: Write
menu driven program that defines and call the following
functions:
a. Add records in the table
b. Update the salary of trainer whose updated salary
and Tid is entered by user.
c. Delete the record of trainer whose Tid is entered by
user.
d. Display all the records.
PROGRAMS
CODING:
PROGRAMS
OUTPUT:
PROGRAMS
PROGRAM 19: Consider the table Loan_Accounts.
Write MY SQL commands and give outputs for SQL
queries:
Acc_n Cust_nam Loan_a Installment Int_rat Start_dat
e
o1 mt s 36 e e 19-07-
R.K.
2 Gupta 300000 48 12.00 2009
3 S.P. 50000 36 10.00 22-03-
Sharma 0 2008
4 60 NULL
K.P. Jain 30000 08-03-
5 0 36 10.00 2007
M.P.
6 Yadav 80000 60 06-12-
12.50
0 2008
7 S.P. 48 12.50
Sinha 20000 03-01-
a. Display the details of all the records of Loan_Account
b. Display the details of all the loans with less
than 40 instalments
c. Display the details of all the loans whose rate of
interest is NULL
d. Display the details of all the loans whose rate of
Interest in not null
e. Display the amounts of various loans from the
table Loan_Accounts. A loan amount should appear
PROGRAMS
only once.
PROGRAMS
PROGRAM 19: (*continued)
f. Display the number of instalments of various loans
from the table Loan_Accounts. An instalment should
appear only once.
g. Display the details of all the loans started after 31-
12-2008 for which the number of instalments are more
than 36.
h. Display the Cust_Name and Loan_Amount for all
the loans which do not have number of instalments
36.
i. Display the Cust_Name and Loan_Amount for all
the loans for which the loan amount is less than
500000 or int_rate is more tyhan 12.
j. Display the details of all the loans whose
Loan_Amount is in the range 400000 to 500000
(Using Between Operator)
[Link] the details of all the loans whose Start_Date
is in the range of 01-01-2007 TO 31-12-2007. (Using
Between Operator)
l. Display the Acc_no, Cust_Name and Loan_amount
for all loans for which the cust_Name ends with
‘Sharma’.
m. Display the Acc_no, Cust_Name andLoan_amount
for all loans for which the cust_Name ends with ‘a’.
PROGRAMS
n. Display the details of all the loans in the ascending
order of their Loan_Accouint.
o. Delete the records of all the loans whose start
date is before 2007.
PROGRAMS
PROGRAM 19: (*continued)
p. Delete the records of all the laons of K.P. Jain.
q. Add another column category of type char(1) in
the loan table
OUTPUT:
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):
PROGRAMS
PROGRAM 20: In a database create the following
tables with suitable constraints:
TI TNAME CITY HIREDAT SALAR MOBILE
D Sunain Mumb E 2001- Y 51259125
10 a ai 01-20 9000 62
1 Anamik Delhi 2015-08- 0 59885412
11 36
10 a Kota 8500
2 2016-07- 0 55452102
Minaks Mumb 22 50
10 7500
3 hi ai Kota 2020-03- 0 51211220
08 12
Rahul above)
(*Table: Trainer, Delhi
(*Table: Course, below)
CID CNAME FEES STARTDATE TID
C201 AGDCA 22000 2021-01-15 101
C20 ADCA 15000 2021-02-22 103
2
C20 DCA 10000 2020-09-12 102
3
C20 DDTP 9000 2020-10-05 104
4
C20 DHN 20000 2021-04-01 101
5
C20 0 LEVEL 18000 2020-04-01 105
PROGRAMS
6
PROGRAMS
OUTPUT:
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):