Professional Documents
Culture Documents
AMBARNATH
PRACTICAL LIST 2023-24
CLASS: XII
SUB: COMPUTER SCIENCE
KENDRIYA VIDYALAYA AMBARNATH
PRACTICAL LIST
CLASS: XII
SUB: COMPUTER SCIENCE
SESSION 2023-24
Index
Sr.
Name of the Experiment/Activity
No.
3. Program to read a text file and count and display different types of characters in the file.
4. Write a Python program to find smallest word, biggest word words of specific length, count the occurrence of specific words from a
text file.
5. Write a program to read text file and display and count different lines from text file.
6. Write a program to append, count and display specific records in text file.
7. Write a program to modify contents of the text file and copy contents from one file to another file based on condition.
8. Write a program to create a binary file using list and perform search operation on it.
9. Write a program to create a binary file using dictionary and perform read, append and search operations on it.
12. Write a menu driven program to create csv file and append student records such as roll number, marks, total and percentage.
13. Write a program to create csv file and perform search operation on csv file using different criteria.
14. Write a program to copy contents containing phonebook of a csv file into another csv file.
15. Write a program to implement stack in Python using list and perform Push and Pop operations on it.
18. Integrate MySQL with Python by importing the MySQL module to search student using rollno, name, age, class and if present in
table display the record, if not display appropriate method.
19. Write a program to connect with database and update and delete the record from database.
Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
1 Jugal 34 Computer Sc 10/01/2017 12000 M
2 Sharmila 31 History 24/03/2008 20000 F
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
7 Shiv Om 44 Computer Sc 25/02/2017 21000 M
8 Shalakha 33 Mathematics 31/07/2018 20000 F
Table : Posting
P_ID Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi
27',30000,'M');
mysql> insert into teacher values(7,'Shiv Om',44,'Computer Sc','2017-
02-25',21000,'M');
mysql> insert into teacher values(8,'Shalakha',33,'Mathematics','2018-
07-31',20000,'F');
17) Display details of employees whose name start with ‘S’ and
ends with ‘a’
Ans:
import os
import platform
import mysql.connector
mydb=mysql.connector.connect(host="localhost",\
user="root",\
passwd="root",\
database="student",charset="utf8")
print(mydb)
mycursor=mydb.cursor()
def stuview():
print("Select the search criteria : ")
print("1. Roll")
print("2. Name")
print("3. Age")
print("4. Class")
print("5. All")
ch=int(input("Enter the choice : "))
if ch==1:
s=int(input("Enter roll no : "))
rl=(s,)
sql="select * from stud where roll=%s"
mycursor.execute(sql,rl)
elif ch==2:
s=input("Enter Name : ")
rl=(s,)
sql="select * from stud where name=%s"
mycursor.execute(sql,rl)
elif ch==3:
s=int(input("Enter age : "))
rl=(s,)
sql="select * from stud where age=%s"
mycursor.execute(sql,rl)
elif ch==4:
s=input("Enter Class : ")
rl=(s,)
sql="select * from stud where clas=%s"
mycursor.execute(sql,rl)
elif ch==5:
sql="select * from stud"
mycursor.execute(sql)
res=mycursor.fetchall()
print("The Students details are as follows : ")
print("(ROll, Name, Age, Class)")
for x in res:
print(x)
runAgain()
Output is:
Answers:
[1] select * from movie ;
Output:
3. select movieid, movie name, production cost + business cost “total earning” from
movie ;
4. select movie_id, movie name, production cost from movie where product is >150000
and <1000000 ;
Answers:
[1] select pow(5,3) ;
M1 2021/12/2 1 2 107 93
0
M3 2021/12/2 1 3 86 81
2
M4 2021/12/2 2 4 65 67
3
M5 2021/12/2 1 4 52 88
4
M6 2021/12/2 2 3 97 68
5
Answers:
[1] create database sports
[2] Creating table with the given specification
desc team;
Inserting data:
1. Display the matchid, teamid, team score who scored more than 70 in first inning
along with team name.
2. Display matchid, team name and second team score between 100 to 160.
3. Display matchid, team names along with matchdates.
4. Display unique team names
5. Display matchid and match date played by Anadhi and Shailab.
Answers:
[1] select match_details.matchid, match_details.firstteamid, team.team
name,match_details.firstteamscore from match_details, team where
match_details.firstteamid=team.teamid and
match_details.firstteamscore>70;
[2] select matchid, team name, second team score from match_details, team were
match_details.secondteamid=team.teamid and match_details.secondteamscore
between 100 and 160;
[4] select dcode,avg(unit price) from stock group by dcode having avg(unit price)>5;