12 List of Prog 2023

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Python Programs and SQL Questions for the Practical Record File for 2023-24

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

2. Write an interactive menu driven program to do the following:


• Write a Python function to input a positive integer (say n); calculate and display number of digits, sum of
the digits and product of the digits
• Write a Python function to input a positive integer (say n); calculate and display number of even digits,
number of odd digits, sum of the even digits and the sum of the odd digits, average of the even digits and
the average of the of odd digits
• Write a Python function to input a positive integer (say n); calculate and display number of even digits,
number of odd digits, product of the even digits and the product of the odd digits
• Write a Python function to input a positive integer (say n); check for Fibonacci Number
• Write a Python function to input two positive integers (say a & b); calculate and display HCF and LCM
of the two integers (without using math.gcd(), math.lcm())
• Exit from the menu and quit the program

3. Write an interactive menu driven program to do the following:


• Write a Python function to input a positive integer (say n); check for Perfect Number
• Write a Python function to input a positive integer (say n); check for Prime Number
• Write a Python function to input a positive integer (say n); check for Palindrome Number
• Write a Python function to input a positive integer (say n); check for Armstrong Number
• Exit from the menu and quit the program

4. Write an interactive menu driven program to do the following:


• Write a Python function to input a positive integer (say n); check for Factorian Number
• Write a Python function to input a positive integer (say n); check for Harshad Number
• Write a Python function to input a positive integer (say n); check for Happy Number
• Write a Python function to input a positive integer (say n); generate and display first n Fibonacci numbers
and at the end display the sum of the Fibonacci numbers (assume first two Fibonacci numbers are 1 and
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

Class XII Page 3 / 6 Subject: Computer Science (083)


Python Programs and SQL Questions for the Practical Record File for 2023-24
• Write a Python function to update binary data file MARKS.DAT by increasing PRAC by 2 where PRAC
is less than 26 (recalculate TOTAL) (use a temporary file for updating); display an appropriate message
after updating
• Write a Python function to delete all the records from the binary data file MARKS.DAT where
TOTAL<70 (use a temporary file for deletion); display an appropriate message after deletion
• Exit from the menu and quit the program

13. Write a menu driven program to do the following:


• Write a Python function to append the following lines in the text file IPL2021.TXT:
On 30-Jan-2021, the BCCI announced that they were confident
to host the tournament in India. The BCCI were considering
to host the tournament in a few shortlisted cities, which
included Kolkata, Delhi, Bangalore, Ahmedabad and Chennai,
with Mumbai as an additional option.
• Write a Python function to read and display the text file IPL2021.TXT on the screen; At end display
number of characters present in the text file
• Write a Python function to read the text file IPL2021.TXT and display number of uppercase, number of
lowercase, number of digits and number of special characters present in the text file
• Write a Python function to read the text file IPL2021.TXT and display number of uppercase consonants,
number of uppercase vowels, number of lowercase consonants and number lowercase vowels, number of
white-space characters and number of special characters excluding white-space characters present in the
file
• Exit from the menu and quit the program

14. Write a menu driven program to do the following:


• Write a Python function to read and display the text file IPL2021.TXT on the screen. At end display
number of words present in the text file
• Write a Python function to read the text file IPL2021.TXT and display number of times words 'THE',
'AN' and 'A' appear in the text file (count ignoring case). Count the articles separately.
• Write a Python function to read the text file IPL2021.TXT and display number of words starting with
vowel (count ignoring case)
• Write a Python function to read the text file IPL2021.TXT and display number of words at least two
vowels (count ignoring case)
• Write a Python function to read the text file IPL2021.TXT and display number of words containing at
most 6 characters
• Exit from the menu and quit the program

15. Write a menu driven program to do the following:


• Write a Python function to read and display the text file IPL2021.TXT on the screen. At end display
number of lines present in the text file
• Write a Python function to read the text file IPL2021.TXT and display number of lines not starting with
vowel (count ignoring case)
• Write a Python function to read the text file IPL2021.TXT and display number of alphabets present in
every line
• Write a Python function to read the text file IPL2021.TXT and display number of special characters
present in every line
• Write a Python function to read the text file IPL2021.TXT and display number of words present in every
line
• Exit from the menu and quit the program

Class XII Page 4 / 6 Subject: Computer Science (083)

You might also like