Professional Documents
Culture Documents
Section – C
return val
26. pYTHOnN#
Section – D
27. (i) Cno Count(*) Max(amount) 31. (i) ALTER TABLE STUDENTS DROP PHONE;
101 2 1500 (ii) SELECT NAME, GAME FROM STUDENTS, SPORTS
WHERE STUDENTS. ADMNO=SPORTS. ADMNO
103 2 12000 AND ADDRESS IS NOT NULL;
(ii) Cno Amount (iii) SELECT NAME, COACHNAME FROM STUDENTS,
103 2000 SPORTS WHERE CLASS LIKE “12%” AND
STUDENTS.ADMNO = SPORTS. ADMNO;
101 1000
(iv) SELECT COUNT(*) FROM STUDENTS, SPORTS
(iii) Count (Distinct Cno) WHERE GAME=”VOLLEYBALL” AND STUDENTS.
3 ADMNO = SPORTS. ADMNO;
Section – E
if rec[0]==cno:
print(rec)
33. (i) f.close()
34. (i) The r mode allows only reading of files. Whereas (ii) import MySQLdb
the r+ mode allows both reading and writing. d b = M y S Q L d b . c o n n e c t ( ‘ l o c a l h o s t ’ ,
(ii) def convert(): ‘Admin’,‘Admin@pwd’, ‘cosmetics’)
import pickle cursor=db.cursor()
f=open(“Aadhar.dat”,”r”)
sql=”””Select*from Product where
f1= open(“wbaadhar.dat”,”w”) Manufacturer=%s”””
alist=[] m_query=(‘ABC’)
nalist=[] try:
alist=pickle.load(f) cursor.execute(sql, m_query)
for rec in alist: results = cursor.fetchall()
if rec[2]==”WB”: print (“Product ID, Product Name,
nalist.append(rec) Manufacturer, Price”)
pickle.dump(nalist,f1) for row in results:
f.close() P_ID = row[0]
f1.close() ProductName = row[1]
OR Manufacturer = row[2]
(i) a and a+ mode places the cursor at the end of
Price = row[3]
the file.
print (“%s %s %s %s” % \ (P_ID,
(ii) def search(cno):
ProductName, Manufacturer, Price))
import pickle
except:
f=open(“consumtion.dat”,”r”)
print (“Error: unable to fetch data”)
clist=[]
cursor.close()
clist=pickle.load(f)
db.close()
for rec in clist:
qqq