Python Program For CBSE Prac
Python Program For CBSE Prac
Write an interactive menu driven program to do the following without using any list related function:
• 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
• Write a Python function to calculate and display the sum and the average of odd integers present in the
list; calculate and display the sum and the average of even integers present in the list without using sum(),
len() or any list methods
• Write a Python function to find and display maximum value and minimum value present in the list along
with their position without using max(), min() or any list methods.
• Exit from the menu and quit the program
2. A Binary data file MARKS.DAT has following data (every record is a list):
ROLL,NAME,THEO,PRAC,TOTAL
1,KUNAL GUPTA,53.0,28.0,81.0
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:
29,SIDDHARTH DAS,51.0,27.0,78.0
30,SUDHIR SINGH,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 where THEO>60
• Write a Python function to input student's ROLL, delete the record containing inputted ROLL from the
binary data file 'MARKS.DAT'. If the inputted ROLL is not found, then display an appropriate message
• Exit from the menu and quit the program
4. Write an interactive menu driven program to do the following without using any list related function:
• 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
• Write a Python function to calculate and display the sum and the average of odd integers present in the
list; calculate and display the sum and the average of even integers present in the list without using sum(),
len() or any list methods.
• 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, list methods, sum() and len() function
• Exit from the menu and quit the program
7. Write an interactive menu driven program to implement a stack using a list. Stack contains billing data:
mobile (8-digit integer), name (string), amount (floating point) and discount calculated as:
Amount <=2000 >2000 and <=5000 >5000 and <=10000 >10000
Discount 0 5% of Amount 10% of Amount 15% of Amount
The billing data also contains netamt (net amount) calculated as amount-discount. Menu options are:
• Write a Python function to insert a billing data in the stack
• Write a Python function to delete a billing data from the stack
• Write a Python function to display the content of stack
• Exit from the menu and quit the program
8. A Binary data file MARKS.DAT has following data (every record is a list):
ROLL,NAME,THEO,PRAC,TOTAL
1,KUNAL GUPTA,53.0,28.0,81.0
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:
29,SIDDHARTH DAS,51.0,27.0,78.0
30,SUDHIR SINGH,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 where TOTAL>=90
• Write a Python function to update records of the binary data file 'MARKS.DAT' by increasing THEO by
3 for those records where THEO < 50. Update the field TOTAL also.
• Exit from the menu and quit the program
10. Write a menu driven program to do the following using only input(), print(), chr() & ord():
• Write a Python function to input a string (contain uppercase, lowercase, digit and special characters);
count and display the number of uppercase characters, number of lowercase characters, number of digits
and number of special characters present in the inputted string
• Write a Python function to input a string (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 (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 (containing uppercase, lowercase, digit and special characters);
obtain a new string by toggling the case of alphabets present in the string; display the toggled string
• Write a Python function to input a string; check whether the inputted string is a Palindrome or not (don’t
use slice)
• Exit from the menu and quit the program
11. A CSV file TEACHER.CSV has following data:
CODE,NAME,SUBJECT,DESIG,NOP
1001,ADITI JAIN,PHYS,HOD,20
Write an interactive menu driven to do the following (using CSV module):
• Append following records(lines) in the file TEACHER.CSV
1019,NUPUR CHACKO,MATH,PRT,30
1020,MANAS KHER,PHYS,PRT,30
• Write a Python function to read the and display the CSV file. At the end display number of records (lines)
where DESIG is either PGT or TGT.
• Input teacher's CODE, if the CODE is found in the file, then delete the record containing inputted CODE
from the CSV file. If the inputted CODE is not found, then display an appropriate message
• Exit from the menu and quit the program
For MySQL, please refer to the questions from the List of Programs for the Record file.
Viva will be based on your CS Project, Python, Database & MySQL and Networks.