12 CS Practical File 2023-24
12 CS Practical File 2023-24
1. Write a function to open the text file ABC.txt and count the number of wordsthat start
with ‘the’, like the, their, they, them, these etc.
2. Write a Python program to count all lines in the file ABC.txt having ‘a’ as thelast
character.
3. Write a Python program to count the number of digits in the text file DIGIT.txt.
4. Write a function to transfer all lines starting with a vowel from ORIGIN.txt toNEW.txt.
5. Write a Function to read data from a text file DATA.TXT, and display those words, which
are less than 4 characters.
6. Write a function to add (append) Employee records (Empno, name and address
,salary)onto a Binary file.
7. Write a function to Delete a Student record (Rollno, name, class, section, mobileno,
marks) in a binary file named Student.dat. Record will be deleted based on Rollno
passedas parameter to the function.
8. Write a function to Update marks of a Student record (Rollno, name, marks)in a binary
file named Student.dat. Record will be updated based on Rollno passed as parameter to the
function.
9. Write a program to display the record of those patients whose cholesterol is more
than 250 and Resting BP is less than 125 from a file the “patient.csv”.
10. Write a program to display the Blood sugar of those patient whose name either starting
with ‘O’ or ending with ‘r’ and Age is more than 70 from file the “patient.csv”.
11. Write a program to display the content of row in reverse order from the file
“patient.csv”.
PROGRMS ON LIST, STRING & DICTIONARY USING FUNCTION:
12. Write a program using function to input a string (word). Convert it into lowercase
letters. Count and print the frequency of each alphabet present in thestring. The output
should be given as:
Output :
The original list : [10, 20, 30, 10, 40, 20, 50]
The Duplicate list : [10, 20]
14. Write a program to input a string and display it in the descending order ofalphabets
using bubble sorting technique.
15. Write a program to input two dictionary and then subtract the values of twodictionary.
Output :
The original dictionary 1 : {'gfg': 6, 'is': 4, 'best': 7}
The original dictionary 2 : {'gfg': 10, 'is': 6, 'best': 10}The
Difference dictionary is : {'gfg': 4, 'is': 2, 'best': 3}
16. Write a Program to connect with database and store record in employee table
(empno,empname, department, salary) and display entire records.
17. Write a Program to connect with database and search a record from employee
table(empno, empname, department, salary) based on empno and display records.
18. Write a Program to connect with database and update a record from employee table
(empno, empname, department, salary) based on empno and display records.
19. Write a Program to connect with database and delete a record from employee
table(empno, empname, department, salary) based on empno and display records.
QUERY ON MYSQL:
20. Consider the following table Prepaid and answer the below-given questions:
(I) To display customer details who are using Jio and vodafone.
(II) To display unique connection from the table.
(III) To display maximum plan amount for each connection.
(IV) To display the count of each model type.
(V) To display customer details whose names end with ‘k’.
21. Consider the following table stock table to answer the queries:
22. Create a table Club in the database Sports by using the following constraints and execute
the following queries:
(a) Display the names of those coaches whose name start with the letter “A” and ends with
“H”.
(b) Display the sum of Pay of the Swimming coaches
(c) Display the name of the coaches and their age in descending order of age.
(d) Increase the pay of all the coaches by 10%.
(e) Remove Primary key constraint from Coach_Id and add Coach_Name as primary key.
(f) Delete the records of the coaches of Swimming.
(g) Add a new column Gender in the table “Club”
23. Create a table “Product” in the database “Stock” by using the following constraints and
execute the following queries:
25. Consider the following tables PRODUCT and CLIENT. Write SQL commands for the following
statements (i) to (iv):
Table: PRODUCT
PID ProductName Manufacturer Price
Table: CLIENT
CID ClientName City PID
(a) To display the details of those clients whose City is Delhi in alphabetical order of client name.
(b) To display the average price of all products, manufacturer wise.
(c) To display the Product Name and Client Name of clients whose manufacturer is ‘ABC’.
(d) To increase the Price of all Products by 100.