Marking Scheme : Computer Science
1 C 5 A 9 B 13 A 17 B
2 A 6 A 10 B 14 A 18 C
3 A 7 B 11 C 15 B
4 D 8 12 FALSE 16 D
8. It is an unexpected situation that arises during execution of a programme.
19. def Check_Error( arg2, arg1=5): 2
if arg1= =arg2:
s=str(arg1) + str(arg2)
elif arg1> arg2:
print(‘Do it again’)
20, 35 # 90 2
55 # 85
21. GOOdbbDAy 2
22. def Text_File(): 2
f=open('olympics.txt','r')
s=f.read()
s=s.split()
for i in s:
if i[0]=='I':
print(i[::-1],end=' ')
else:
print(i,end=' ')
f.close()
OR
def Long_Lines():
f=open('olympics.txt','r')
s=f.readlines()
for i in s:
w=i.split()
if len(w)>5:
print(i)
1
f.close()
Page
HP 1
23. Primary key uniquely identifies each and every tuple in a relation. 2
Regcode should be taken as primary key as it’s values are unique.
24. The first query produces 20 as there are 20 records. 2
The second query counts number of tnames and there must be 3 NULL values. That is why it
produces 17.
25. a) True 2
b) floor( )
26. def countDigit (): 3
f=open('alnum.txt','r')
text=f.read()
dig=al=0
for i in text:
if i.isdigit():
dig+=1
elif i.isupper():
al+=1
print(dig, al)
f.close()
countDigit( )
OR
def India():
f=open('alnum.txt','r')
text=f.read()
text=text.split()
ind=0
for i in text:
if i.upper()=='INDIA':
ind+=1
print(ind)
f.close()
27. a) 3
Create table tech_course
(
ci dint primary key,
cname varchar(12),
2
Page
fees dec(8,2),
HP 2
startdate date,
tid int
);
b)
Drop table Delete
It is a DDL command It is a DML command
It deletes all records It deletes records from a table
It deletes the table also It does not delete the table
28. a) 3
ACode Name Type City
A01 Amrita Savings Delhi
A02 Parthodas Current Mumbai
A03 Miraben Current Nagpur
b)
i) distinct(tid) ii) tid count(*) min(fees) iii) cname iv) avg(fees)
___________ ___ _______ ________ _____ _______
101 101 2 12000 App Devmpt 16330
NULL Digital mkt
102104
103
29. def Read_Car_Data ( ): 3
f=open('car.dat','br')
try:
while True:
x=pickle.load(f)
if x[2]>5000000:
print(x[0],x[1],x[2],x[3])
except:
f.close()
OR
def Read_Car_Data ( ):
f=open('car.dat','br')
tot_price=count_rec=0
try:
while True:
x=pickle.load(f)
tot_price+=x[2]
count_rec+=1
3
Page
except:
HP 3
f.close()
print('Average price of car :',tot_price/count_rec)
30. a) 2
67#6#
b)
select * from customer where cust_name is not null ; 1
31. a) 1
read( ) load( )
It reads unstructured data It reads structured data 1
It is used to read from text file It is used to read from binary file
f.read(20) pickle.load(f)
b)
With open(‘F:\\newfiles\\goods.txt’) as fobj:
c)
1
i) ‘a’ mode opens a file in append mode. Previous file content is not erased and the file pointer is
positioned at the end of the file. ‘w’ mode opens a file is write mode. Previous file content is
erased.
1
ii) newline
32. a) 3
i)
def Add_Mob():
f=open('mobile.dat','ab')
prodid=int(input('Product Id :'))
prodname=input('Product name :')
brand=input('Brand :')
price=float(input('Price :'))
rec={}
L=[prodname,brand,price]
rec[prodid]=L
pickle.dump(rec,f)
f.close()
ii)
def Get_Mob():
4
f=open('mobile.dat','rb')
Page
try:
HP 4
while True:
x=pickle.load(f)
if x[prodid][1]=='Apple':
print(x)
except:
f.close()
b) Degree : Number of attributes of a relation is known as degree. 1
Cardinality: Number of tuples of a relation is known as cardinality.
33. (i) Select distinct carrier from flight ; 5
(ii) Select * from flight where fare> 10000 ;
(iii)Select fno, pname, fare from flight where carrier=’Indigo’ order by age ;
(iv) Select pname from flight where carrier like ‘In%’ ;
(v) Select max(fare), min(fare) from flight group by carrier ;
34. a) Use school ; 5
Show tables ;
b) Alter table students add email varchar(30) unique
c) Update students set score=score+5 where grade=’12K’ ;
d) Delete from students ;
e) Select cname, status from tech_course t, status s where t.tid=s.tid ;
35. (a) csv 5
(b) csv_w.writerow(fields)
(c) csv_w.writerows(rows)
(d) csv_r=csv.reader (f,delimiter=',')
(e) row[0]
5
Page
HP 5