You are on page 1of 3

ANSWERS

Self Assessment Paper-3


COMPUTER SCIENCE

Section – A 10. Option (A) is correct.



Explanation: pickle is the Python library module
1. False which need to be imported to invoke the dump()
Explanation: Text files have extension .txt. and load() functions.

2. Option (A) is correct. 11. Option (B) is correct.


Explanation: The Like clause can be used to match
Explanation: Bus Topology is also called as Linear
patterns in a string. topology because of its structure.
12. Option (C) is correct.
3. Option (A) is correct.

Explanation: The tell() function returns the current
Explanation: 362//7 + 26%52 – 2**8 +5
= 51 + 26 – 256 + 5 position of the file pointer.
= 77 – 256 + 5 13. (b) False
= –174
Explanation: Handling exceptions is not
4. False compulsory , but is a good practice.
Explanation: The endswith() function checks
14. Option (B) is correct.
whether a string ends with a particular substring or
Explanation: DDL is data definition language.
not Commands in this category are used for data
5. Option (A) is correct. definition.
Explanation: Alter command can be used to add a
15. Star
new constraint to a table. Explanation: Since connections are independent in
6. Option (A) is correct. star topology , error detection is easy
Explanation: An URL starts from Protocol name Ex: 16. Option (A) is correct.
http://www.cbse.nic.in Explanation: If no mode is specified a text file is
7. Option (A) is correct. opened in read mode by default.
H
E
17. Option (D) is correct.
L
Explanation: It is possible to delete/remove
L element(s) from the list. There are many ways of
O doing so:
6
(i) If index is known, we can use pop() or del
7
8 (ii) If the element is known, not the index, remove()
9 can be used.
Explanation: The code prints the alphabets of the (iii) To remove more than one element, del() with list
string in uppercase and the digits incremented by 5. slice can be used.
8. Option (A) is correct. 18. Option (A) is correct.
Explanation: p+q>r and not q or q%5==0

Explanation: Illegal operations can raise exceptions.
55> 26 and not 30 or 30%5==0
True and False or True There are plenty of built-in exceptions in Python
False or True that are raised when corresponding errors occur.
True We can view all the built-in exceptions using the
9. Option (C) is correct. built-in local() function as follows:
Explanation: Opens the file in read-only mode. So, print(dir(locals()['__builtins__']))
we can’t write any data to the file.
2 Oswaal CBSE Sample Question Papers, Computer Science, Class-XII

Section – B So, Bank A/C Num and Aadhar Num are the
candidate keys for the table.
Primary key: Aadhar Num
19.
(i) (a) OFC : Optical fibre cable Alternate key: Bank A/C Num
(b) HTML : Hypertext markup language 25. [1, 67, 3]
(ii) Obtaining the IP address of a web resource/ 2
web site from the domain name is called
Domain name resolution.
OR
Section – C
(i) Bus topology 26. 4
(ii) Two advantages of bus topologies:
27.
(i) MAX (PRICE) MIN (PRICE)
• Easy to connect and install
28000 1100
• Involves a low cost and installation time
(ii) PNAME
20. Number = 250 DIGITAL CAMERA 14X
while Number<=1000: CAR GPS SYSTEM
if Number>=750: (iii) DISTINCT SUPCODE
print (Number) S01
Number=Number+100 S02
else: S03
print (Number*2)
28. def countmy( ):
Number=Number+50
f= open("DATA.TXT","r")
21. def newtuple(t1,t2): count =0
L1=list(t1) x=f.read()
L2=list(t2) word=x.split()
L3=L1 + L2 for i in word:
t3=tuple(L3) if i == "my":
OR count=count+1
def Perfect(num):
print("my cocurs",count,"times")
s=0
for a in range(1,num): OR
if num%a==0: def countblankspace():
s+=a fname = "story.txt"
if s==num: count=0
return True with open(fname, 'r') as f:
else: l=f.readline()
return False for line in l:
22. [[[1, 2, 3, 17, 5], [6, 7, 8]], 200] for word in line:
[[[1, 2, 3, 17, 5], [6, 7, 8]], 200] for char in word:
23. (i) print(L[1][1]) if char.isspace():
(ii) del Lst[3:6] count=count+1
OR print("No. of space=",count)
70 50 20
f.close()
90 40 50
90 50 40 29.
(a) Select Distinct(PLATFORM) from
moviedetails;
24. Create table Professor(PID int Primary key, Pname (b) Select Title , Rating from Moviedetails where
varchar(30) NOT NULL, Dept varchar(20) NOT
NULL, Salary float(8,1) check (salary>10000)); language IN (“English”,”Hindi”)
OR (c) Update moviedetails set Platform=”Netflix”
where title=”Uri”;

A primary key is a value that can be used to identify
a unique row in a table. While an alternate key is 30. N=[12,13,34,56,21,79,98,22,35,38]
any candidate key which is not selected to be the def PUSH(S,N):
primary key. S.aapend(N)

Example Consider table PERSON def POP(S):
Name Bank A/C Num Aadhar Num if S!=[]:
return S.pop()
Rahul 1290889909 1800991222 else:
Gopal 1909090909 1908909090 return None
ST=[]
Bhavish 1902090909 8298291282
for k in N:
Answers 3
if k%2==0: for rec in plist:
PUSH(ST,K) if rec[3]==wrd:
while True: newlist.append(rec)
if S!=[] f.close()
print(POP(ST).end="") pickle.dump(newlist,f1)
else: f1.close()
break OR
(i) Insert ()
(ii) import pickle
Section – D def Modify(ItemId):
f=open(“Inventory.dat”,”r”)
31.(i) Update mobilemaster set m_price=m_price
–m_price*0.1; Itlst=pickle.load(f)
(ii) Select m1.m_name,m1.m_company,m2.m_ newrec=[]
supplier from mobilemaster m1, mobilestock for rec in Itlst:
m2 where m1.m_id=m2.m_id; if rec[0]== ItemId:
(iii) Select m_id,m_mf_date,m_company in=input (“Enter New Item name
from mobilemaster where year(m_mf_ :”)
date)>”2015-12-31”; iq= input (“Enter New quantity
(iv) Select Max(m_qty) , min(m_qty) from :”)
mobilestock;
ro= input (“Enter Reorder :”)
32. import csv ct= input (“Enter category :”)
def transfer(Sid):
newrec.append([in,iq,ro,ct])
stklst=[]
f=open(“stock.csv”) else :
f1= open(“newstock.csv”) newrec.append(rec)
fr=csv.reader(f) f.close()
fw=csv.writer(f1) f=open(“Inventory.dat”,”w”)
for rec in fr: pickle.dump(newrec,f)
if rec[0]==Sid:
f.close()
stklst.append(rec)
csv.writerows(stklst) 35.
(i) The Group by clause is used to group records
f.close() of a table on common values of a column to
f1.close() get aggregate results.
(ii) import MySQLdb
db = MySQLdb.connect('localhost',
'EmpDetail', 'Emp@123','EmpDB')

Section – E cursor=db.cursor()
sql="""UPDATE Employee SET
Salary=Salary+5000 WHERE
33.
(i) Finance block because it has maximum city='%s'/(Delhi)"""
number of computers. try:
(ii) db.execute(sql)
Finance
db.commit()
except:
db.rollback()
db.close()
Conference Human Resource
OR
(i) cursor.fetchmany(SIZE)
(iii) Satellite link
(ii) import MySQLdb db=MySQLdb.connect
(iv) Switch ("localhost","Admin","Ad123","Sal
(v) Man (Metropolitan Area Network) as this es")
network can be carried out in a city network. cursor=db.cursor()
34.
(i) The r+ mode is used in text and csv files. The cursor.execute("DROP TABLE IF
rb+ mode is used in binary files. EXISTS SALES_Representative")
(ii) import pickle sql="""CREATE TABLE SALES
def transfer(wrd): Representative (slsrnumb integer,
newlist=[] slsrname char(25)not null,
f=open(“Hospital.dat”,”r”) slsraddr null, totcomm double,
commrate double)"""
f1=open(“newfile.dat”,”w”)
cursor.execute(sql)
plist=pickle.load(f)
db.close()
qqq

You might also like