Professional Documents
Culture Documents
12 List of Prog 2023
12 List of Prog 2023
12 List of Prog 2023
Python Programs
1. Write an interactive menu driven program to do the following:
• Input a floating point value (say x) and an integer value (say n) and find the sum of the sequence given
below without using **, pow(), math.pow() and math.factorial():
𝑥 𝑥2 𝑥3 𝑥𝑛
1 + + + + ⋯+
1! 2! 3! 𝑛!
• Input a floating point value (say x) and an integer value (say n) and find the sum of the sequence given
below without using **, pow(), math.pow() and math.factorial():
𝑥 𝑥2 𝑥3 𝑛
𝑥𝑛
1 − + − + ⋯ + (−1)
1! 2! 3! 𝑛!
• Input a floating point value (say x) and an integer value (say n) and find the sum of the sequence given
below without using **, pow(), math.pow() and math.factorial():
𝑥2 𝑥4 𝑥6 𝑥 2𝑛
1+ + + +⋯+
2! 4! 6! (2𝑛)!
• Input a floating point value (say x) and an integer value (say n) and find the sum of the sequence given
below without using **, pow(), math.pow() and math.factorial():
𝑥 𝑥3 𝑥5 𝑥 2𝑛−1
1 + + + + ⋯+
1! 3! 5! (2𝑛 − 1)!
• Exit from the menu and quit the program
5. Write an interactive menu driven program to do the following (without using any list methods):
• Write a Python function to create a list with n (n is a user inputted value) random integers and every
integer has 4 digits and display the list on the screen using a loop
Class XII Page 1 / 6 Subject: Computer Science (083)
Python Programs and SQL Questions for the Practical Record File for 2023-24
• Write a Python function to find and display the sum and the average of values present in the list without
using sum() and len() functions.
• Write a Python function to find and display the sum and the average of odd integers; find and display the
sum and the average of odd integers present in the list without using sum() and len() functions.
• Write a Python function to find and display maximum value and minimum value present in the list along
with their position without using max() and min() functions
• Write a Python function to find and display Arithmetic Mean, Geometric Mean and Harmonic Mean of
values present in the list without using the statistics module
• Exit from the menu and quit the program
6. Write a menu driven program to do the following using only input(), print(), chr() & ord():
• Write a Python function to input a string (must contain uppercase, lowercase, digit and special characters);
count and display number of uppercase vowels, number of uppercase consonants, number of lowercase
vowels, number of lowercase consonants, number of digits and number of special characters
• Write a Python function to input a string (must contain uppercase, lowercase, digit and special characters);
obtain a new string by converting the inputted string into an uppercase string; display the new string
• Write a Python function to input a string (must contain uppercase, lowercase, digit and special characters);
obtain a new string by converting the inputted string into a lowercase string; display the new string
• Write a Python function to input a string (must contain uppercase, lowercase, digit and special characters);
obtain a new string by toggling the characters of the inputted string; display the new string
• Write a Python function to input a string; check whether the inputted string is Palindromic or not (without
using slice)
• Exit from the menu and quit the program
7. A CSV file TEACHER.CSV contain teacher's data and every record has following fields:
CODE,NAME,SUBJECT,DESIG,NOP where CODE is int, NAME is str, SUBJECT is str, DESIG is str
and NOP is int
Write an interactive menu driven to do the following (using CSV module):
• Append following records (lines / rows) in the file TEACHER.CSV by taking input from the keyboard
during the run-time:
1019,NUPUR CHACKO,MATH,PRT,30
1020,MANAS KHER,PHYS,PRT,30
• Write a Python function to read and display the CSV file; at the end display number of records present in
the file
• Write a Python function to input teacher CODE; search for the teacher CODE in the CSV file
TEACHER.CSV; if the teacher CODE is found in the CSV file, then display teacher's details, otherwise
display an appropriate message
• Write a Python function to read the CSV file TEACHER.CSV and display the records where SUBJECT
is either PHYS or CHEM; at the end display number of such records found in the file
• Exit from the menu and quit the program
8. A CSV file TEACHER.CSV contain teacher's data and every record has following fields:
CODE,NAME,SUBJECT,DESIG,NOP where CODE is int, NAME is str, SUBJECT is str, DESIG is str
and NOP is int
Write an interactive menu driven to do the following (using CSV module):
• Write a Python function to read the CSV file TEACHER.CSV and display details of teachers where
DESIG is either TGT or PGT; if no record is found then display an appropriate message
• Write a Python function to read the CSV file TEACHER.CSV and display details where SUBJECT is
MATH and NOP>24; at the end display number of such records found in the file
• Write a Python function to update the CSV file TEACHER.CSV by increasing NOP of every PRT by 2
(use a nested list to update the CSV file); display an appropriate message after updating
• Input teacher's CODE, if the inputted CODE is found then delete the record from the CSV file
TEACHER.CSV (delete the record by using a nested list); display an appropriate message after deletion
• Exit from the menu and quit the program
Class XII Page 2 / 6 Subject: Computer Science (083)
Python Programs and SQL Questions for the Practical Record File for 2023-24
9. A CSV file TEACHER.CSV contain teacher's data and every record has following fields:
CODE,NAME,SUBJECT,DESIG,NOP where CODE is int, NAME is str, SUBJECT is str, DESIG is str
and NOP is int
Write an interactive menu driven to do the following (using CSV module):
• Write a Python function to input teacher NAME; search for the teacher NAME in the CSV file
TEACHER.CSV; if the teacher NAME is found in the CSV file, then display teacher's details, otherwise
display an appropriate message
• Write a Python function to read the CSV file TEACHER.CSV and display details where SUBJECT is
MATH and DESIG is TGT; at the end display number of such records found in the file
• Write a Python function to update the CSV file TEACHER.CSV by increasing NOP of every TGT by 3
(use a temporary file to update the CSV file); display an appropriate message after updating
• Delete all the record from the CSV file TEACHER.CSV where DESIG is HOD by using a temporary file;
display an appropriate message after deletion
• Exit from the menu and quit the program
10. A Binary data file MARKS.DAT contains student's record as a list: [ROLL,NAME,THEO,PRAC,TOTAL]
where ROLL is int, NAME is str, THEO is float, PRAC is float and TOTAL is float
Write an interactive menu driven program using pickle module to do the following:
• Write a Python function to append following records in the binary data file MARKS.DAT by taking input
from the keyboard during the run-time:
29,SIDDHARTH DAS,51.0,27.0,78.0
30,SUDHIR SIGH,64.0,30.0,94.0
• Write a Python function to read and display the binary data file MARKS.DAT; at the end display number
of records present in the file
• Write a Python function to search for a student's details from the binary data file MARKS.DAT by
inputting ROLL; if the inputted ROLL is found in the file then display student's details, otherwise display
an appropriate message
• Write a Python function to read and display the binary data file MARKS.DAT; at the end display number
of records where THEO>60;
• Exit from the menu and quit the program
11. A Binary data file MARKS.DAT contains student's record as a list: [ROLL,NAME,THEO,PRAC,TOTAL]
where ROLL is int, NAME is str, THEO is float, PRAC is float and TOTAL is float
Write an interactive menu driven program using pickle module to do the following:
• Write a Python function to read the binary data file MARKS.DAT; display the records where
TOTAL>=80 and TOTAL<90; at the end display number of such records found
• Write a Python function to read the binary data file MARKS.DAT; display the records where PRAC<25,
otherwise display an appropriate message if no such record is found
• Write a Python function to input a ROLL to edit a record in the binary data file MARKS.DAT by inputting
new THEO, inputting new PRAC & calculating TOTAL (use a nested list to update the binary file);
display an appropriate message after updating
• Input student's ROLL, if the inputted ROLL is found then delete the record from the binary data file
MARKS.DAT (delete the record by using a nested list); display an appropriate message after deletion
• Exit from the menu and quit the program
12. A Binary data file MARKS.DAT contains student's record as a list: [ROLL,NAME,THEO,PRAC,TOTAL]
where ROLL is int, NAME is str, THEO is float, PRAC is float and TOTAL is float
Write an interactive menu driven program using pickle module to do the following:
• Write a Python function to search for a student's details from the binary data file MARKS.DAT by
inputting NAME; if the inputted NAME is found in the file then display student's details, otherwise display
an appropriate message
• Write a Python function to read the binary data file MARKS.DAT; display the records where THEO>=60;
if no such record is found then display an appropriate message