BAL BHAVAN PUBLIC SCHOOL
COMPUTER SCIENCE
Practical File
Session: 2025-26
Submitted by: Submitted to:
Name – Abbad Alam Ms. Harpreet Kaur Verma
Section - XII - A
Roll Number -
INDEX
Serial Teacher’s
Program
no. Signature
Write a program to check a number whether it
1
is palindrome or not.
Write a program to display ASCII code of a
2
word ‘Help’ and vice versa.
Write a python program to sum the sequence
3 given below. Take the input n from the user.
1+1/1!+1/2!+1/3!+ +1/n!
⋯
Write a python program to calculate the nth
4
term of Fibonacci Series.
Write a python program to search any word in
5
the given string/ sentence.
Write a python code to handle the zero
division error, Value error, type error. Display
6
the output of all the error cases and without
error case.
INDEX
Serial Teacher’s
Program
no. Signature
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
7 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.
Write a program to read a text file line by line
and display each word separated by '#'. Also
8
display the content of text file first and then
display the desired output.
INDEX
Serial Teacher’s
Program
no. Signature
Write a program to count the number of
vowels present in a text file. Also display the
9
content of text file first and then display the
desired output.
Write a program to count number of words in
10 a file. Also display the content 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 text file. Also
11
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
12 another text file. Also display the content of
text first file first and then display the content
of another file.
INDEX
Serial Teacher’s
Program
no. Signature
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:
14
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
INDEX
Serial Teacher’s
Program
no. Signature
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
15
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".
INDEX
Serial Teacher’s
Program
no. Signature
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
16 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.
INDEX
Serial Teacher’s
Program
no. Signature
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 following functions:
17
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 updated
18
salary and Tid is entered by user.
c. Delete the record of trainer whose Tid is
entered by user.
d. Display all the records.
INDEX
Serial Teacher’s
Program
no. Signature
For the given tables Loan_Accounts. Write MY
19 SQL commands and give outputs for SQL
queries.
In a database create the suitable tables with
20
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 dictionary into 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
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
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
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_no Cust_name Loan_amt Installments Int_rate Start_date
1 R.K. Gupta 300000 36 12.00 19-07-2009
2 S.P. Sharma 500000 48 10.00 22-03-2008
3 K.P. Jain 300000 36 NULL 08-03-2007
4 M.P. Yadav 800000 60 10.00 06-12-2008
5 S.P. Sinha 200000 36 12.50 03-01-2010
6 P. Sharma 700000 60 12.50 05-06-2008
7 K.S. Dhall 500000 48 NULL 15-03-2008
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 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)
k. Display 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’.
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:
TID TNAME CITY HIREDATE SALARY MOBILE
101 Sunaina Mumbai 2001-01-20 90000 5125912562
102 Anamika Delhi 2015-08-11 85000 5988541236
103 Minakshi Kota 2016-07-22 75000 5545210250
104 Rahul Mumbai 2020-03-08 95000 5121122012
105 Jeetu Kota 2015-08-25 125000 5632896512
106 Dipali Delhi 2015-07-19 69000 5789641100
(*Table: Trainer, above) (*Table: Course, below)
CID CNAME FEES STARTDATE TID
C201 AGDCA 22000 2021-01-15 101
C202 ADCA 15000 2021-02-22 103
C203 DCA 10000 2020-09-12 102
C204 DDTP 9000 2020-10-05 104
C205 DHN 20000 2021-04-01 101
C206 0 LEVEL 18000 2020-04-01 105
PROGRAMS
OUTPUT:
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):
PROGRAMS
OUTPUT (continued):