Oswal Practice Papers CBSE Class 12 Computer Science Solutions (Practice Paper - 10)
Section-A
1. (b) False
Explanation :
Dictionary keys are immutable and lists are mutable data structures.
2. (d) Similar types of values in both the tables
Explanation :
Since a foreign key links tables, it must carry similar values in both the tables.
3. (b) 18.0
Explanation :
The original expressionis:
12/4 + 121**0.5 + 32%7 = 3.0 + 11 + 4
= 18.0
4. (a) Python- Language
Explanation :
The join() function joins list elements with the delimiter specified.
5. (d) Both (a) and (b)
Explanation :
Both describe and drop are DDL commands..
6. (a) Star
Explanation :
Star topology has independent cables connecting the nodes. Hence error detection is easier.
7. (a) 2
0
2
4
Explanation :
The code checks for digits in the string and prints them.
8. (b) Ionart
Explanation :
String[start:end:progression] extracts a substring from start to end -1 progressing with the progression specified.
9. (a) import
Explanation :
Other keywords are inappropriate.
10. Both (a) and (c) are possible options
Explanation :
PICK maxval = 3 minval = 0.
11. (d) All are guided media
Explanation :
All the above media are wired media.
12. (a) num1%10 + num2%10 + num3%10
Explanation :
%10 extracts the last digit from a number.
13. False
Explanation :
Since a number is divided by 0 the ZeroDivisionError occurs.
14. (c) Unique and non blank values
Explanation :
An alternate key may replace a primary key, so it must carry unique and non blank values.
15. (d) Both (b) and (c)
Explanation :
NIC stands for Network Interface Card . It is a hardware that has a permanent address called the MAC address.
16. (d) No module required
Explanation :
The text file handling functions do not require any module to be imported.
17. (a) Both A and R are true and R is the correct explanation for A.
Explanation :
For any types of files the default opening mode is taken as read mode if no mode is specified.
18. (b) Both A and R are true and R is not the correct explanation for A.
Explanation :
Python allows returning multiple values from a function by statements like : return a,b,c
Section-B
19. (i) (a) OFC : Optical Fibre Cable
(b) HTML : Hypertext Markup Language
(ii) Obtaining the IP address of a web resource / web site from the domain name is called Domain name resolution.
20. c=dict()
n=input(“Enter total number”) # Error 1
i=1
while i<=n :
a=input(“enter place”)
b=input(“enter number”)
c[a]=b
i=i+1
print(“place”, “\t”, “number”)
for i in c :
print(i, “\t”, c[i])
21. def Perfect(num):
s=0
for a in range(1,num):
if num%a==0:
s+=a
if s==num:
return True
else:
return False
OR
def void(x):
returnint(x[:2])**2 + int(x{2:])**2
num=input(“Enter the four digit number:–’)
print(void(num))
22. [[[1, 2, 3, 17, 5], [6, 7, 8]], 200]
[[[1, 2, 3, 17, 5], [6, 7, 8]], 200]
23. (i) empdict [“Email”]= [email protected]
(ii) print(t[-1:-4:-1])
24. (i) The wildcards are incorrect. The corrected query is SELECT name FROM teacher WHERE name
LIKE ‘_ _ O%’;
(ii) ALTER TABLE TEACHER MODIFY NAME varchar(40);
25. [ ] & [25, 20, 15, 10]
Section-C
26. 220 20 200
70 50 20
70 20 50
27. (i) MAX (PRICE) MIN (PRICE)
28000 1100
(ii) PNAME
DIGITAL CAMERA 14X
CAR GPS SYSTEM
(iii) DISTINCT SUPCODE
S01
S02
S03
28. def showords():
f=open(“words.txt”)
words=f.read()
lines=words.split(‘ ‘)
for wrd in lines:
if len(wrd) > 5 :
print(wrd)
f.close()
OR
def countlines():
f=open(“players.txt”,”r”)
lines=f.readlines()
print(“Number of lines :”,len(lines))
29. (i) Select Name,SALARY fromEMPLOYEE where Salary IS NULL order by Name;
(ii) SELECT Distinct(DEPTID) from EMPLOYEE;
(iii) Alter table Employee MODIFY DESIG varchar(25);
30. [“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty
Section-D
31. (i) Finance block because it has maximum number of computers.
(ii)
(iii) Satellite link
(iv) Switch.
(v) MAN (Metropolitan Area Network) as this network can be carried out in a city network.
32. (i) The r+ mode is used in text and csv files. The rb+ mode is used in binary files.
(ii) Program:
import pickle
def transfer(wrd):
newlist=[]
f=open(“Hospital.dat”,”r”)
f1=open(“newfile.dat”,”w”)
try:
while True:
plist=pickle.load(f)
for rec in plist:
if rec[3]==wrd:
newlist.append(rec)
except:
f.close()
pickle.dump(newlist,f1)
f1.close()
OR
Program:
import pickle
def Modify(ItemId):
f=open(“Inventory.dat”,”r”)
newrec=[]
try:
while True:
Itlst=pickle.load(f)
for rec in Itlst:
if rec[0]== ItemId:
in=input (“Enter New Item name :”)
iq= input (“Enter New quantity :”)
ro= input (“Enter Reorder :”)
ct= input (“Enter category :”)
newrec.append([in,iq,ro,ct])
else :
newrec.append(rec)
except:
f.close()
f=open(“Inventory.dat”,”w”)
pickle.dump(newrec,f)
f.close()
33. (i) The Group by clause is used to group records of a table on common values of a column to get aggregate results.
(ii) import MySQLdb
db = MySQLdb.connect(‘localhost’, ‘HRMan’, ‘HRMANexe@pwd’, ‘HTMdb’)
cursor=db.cursor()
sql=“““UPDATE Employee set Age=Age+1 where SEX%c’/(‘M’)”””
try:
db.execute(sql)
db.commit()
except:
db.rollback()
db.close()
Section-E
34. (i) Update mobilemaster set m_price=m_price –m_price*0.1;
(ii) Select m1.m_name,m1.m_company,m2.m_supplier from mobilemaster m1, mobilestock m2 where m1.m_id=m2.m_id;
(iii) Select m_id,m_mf_date,m_company from mobilemaster where year(m_mf_date)>”2015-12-31”;
(iv) Select Max(m_qty) , min(m_qty) from mobilestock;
35. (a) import pickle
def AddStudents() :
________ #1 statement to open the binary file to write data
while True:
Rno=int(input(“Rno:”))
Name=input(“Name:”)
Percent=float(input(“Percent:”))
L=[Rno, Name, Percent]
________ #2 statement to write the list L into the file
Choice=input(“enter more(y/n):”)
if Choice in “nN”:
break
F.close()
(b) def GetStudents( ):
Total=0
Count rec=0
Count above 75=0
with open (“STUDENT.DAT”, “rb”) as F :
while True:
try:
________#3 statement to read from the file
Count rec+=1
Total+=R[2]
if R[2]>75:
print(R[1], “has percent=”, R[2])
Count above 75+=1
except:
break
if Count above 75==0:
print(“There is no student who has percentage more than 75”)
average=Total/Count rec
print(“average percent of class=”, average)
AddStudents()
GetStudents()
(i) Which command is used to open the file “STUDENT.DAT” for writing only in binary format? (marked as # 1 in the Python code)
(ii) Which commands is used to write the list L into the binary file, STUDENT.DAT? (marked as #2 in the Python code)
(iii) Which command is used to read each record from the binary file STUDENT.DAT? (marked as #3 in the Python code)
(iv) What Is r+ mode of file opening?
Ans. (i) F= open(“STUDENT.DAT”,’wb’).
(ii) pickle.dump(L,F )
(iii) R = pickle.load(F).
(iv) It opens a file for both reading and writing. The file pointer will be at the beginning of the file
Please Click on Download Now