12 CS MS 08012025
12 CS MS 08012025
11 False 1
12 b) 50#90 1
13 b) BETWEEN 1
14 b)SELECT * FROM PRODUCT ORDER BY PRICE DESC; 1
15 a) update 1
16 c) cursor 1
17 b) POP 1
18 c) Repeater 1
19 b)Cookies 1
20 c)A is True but R is False 1
21 d)A is false but R is True 1
Q.No Section-B ( 7 x 2=14 Marks) Marks
22 List-mutable datatype, it supports item assignment
String-immutable datatype, once created we cannot change the values.
2
Explanation-1 mark
Eg: 1 mark
23 I. in, not in ( 1 mark)
II. is,is not (1 mark) 2
1
a. str.find(‘2024’)
OR
b. len(str)
II.
a. str.isalnum()
OR
b. str.startswith(‘PRE’)
2
f=open("info.txt",'r')
data=f.read()
words=data.split()
for i in words:
if len(i)>4 and i[0].upper() in 'AEIOU':
print(i)
f.close()
show()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for checking the condition and displaying)
OR
def show():
f=open("poem.txt","r")
line=f.readlines()
c=0
for i in line:
c=c+1
v=0
for ch in i:
if ch.upper() in ‘AEIOU’:
v=v+1
print("Line ",c,":" v)
f.close()
30 A)
pharmacy=[]
def Addmedicine(pharmacy,med_data):
pharmacy.append(med_data)
def remove_med(Pharmacy): 3
if pharmacy!=[]:
print(BookStack.pop())
else:
print("Underflow")
def Top_med(pharmacy):
if pharmacy==[]:
3
print("None")
else:
print(pharmacy[-1])
Addmedicine(pharmacy,med_data)
remove_med(pharmacy)
Top_med(pharmacy)
OR
3
0 #1 #2 # (1 mark)
0 #1 #2 #3 #4 #5 # (1 mark)
0# (1 mark)
OR
4
i. Select Vcode, make from Rent_cab where VName like ‘%car%’;
Vcode Make
Color Sum(charges)
Silver 10
Red 9
Max(charges)
30
33 a. def shortlist():
import csv
f=open("registration.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
4
for i in records:
if int(i[3])>=75:
print(i)
f.close()
shortlist()
(½ mark for opening in the file in right mode)
5
(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)
b. def Waiting_list():
import csv
f=open("registration.csv",'r')
c=0
records=csv.reader(f)
next(records, None) #To skip the Header row
for i in records:
if int(i[3])>65 and int(i[3])<75:
c=c+1
return c
f.close()
Waiting_list()
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly returning the counter)
34 i. Select name from games,players where gamename=’Carrom Board’
and games.gcode=players.gcode;
ii. Select game_name, name from games, players where type=’indoor’
and games.gcode=players.gcode;
iii. Insert into players values(6,’Gupta’,105);
4
iv. Select gamename,type,prizemoney from games where prizemoney is
null;
OR
Describe games;
35 def emp_details():
import mysql.connector as mycon
mydb=mycon.connect(host="localhost",user="root",passwd="Admin",database="
finance")
no=int(input("Enter employee number: "))
name=input("Enter the Name: ")
designation=input("Enter designation: ")
doj=input("Enter date of joinih: "))
salary=int(input("Enter salary: "))
mycur=mydb.cursor()
query="INSERT INTO employee VALUES ({},'{}','{}',{},{})"
query=query.format(no,name,designation,doj,salary)
mycur.execute(query)
mydb.commit()
mycur.execute("select * from employee where price>25000")
6
for rec in mycur:
print(rec)
(½ mark for correctly importing the module)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
Question 36 to 37: 5 mark
36 import pickle
def inputdata():
f=open("library.dat",'ab')
n = int(input("Enter the number of books you want to add: "))
for i in range(n):
Book_name=int(input("Enter the book name: "))
Author_name = input("Enter author Name: ")
BookID=int(input("Enter Bookid "))
price=int(input("Enter the price "))
book_data=[Book_name,Author_name,BookID,price]
pickle.dump(book_data,f)
f.close()
def Availablity_check(Book_ID):
f=open("library.dat",'rb')
found=1
try:
while True:
d=pickle.load(f) 5
if d[2]==Book_ID:
print(d)
found=0
except:
break
if found==0:
print(“not available”)
f.close()
def display():
f=open("library.dat",'rb')
c=0
try:
while True:
d=pickle.load(f)
if d[3]>500:
c=c+1
except:
7
break
print("total number of books=",c)
f.close()