You are on page 1of 3

ANSWERS

Self Assessment Paper-1


COMPUTER SCIENCE

13. (b) False


Section – A
Explanation: The finally block executes at the end.
1. True 14. Option (A) is correct.
Explanation: Default arguments to a function have
to be assigned right to left.
15. Radio wave
Explanation: Radiowaves can travel to hilly areas
2. Option (B) is correct. within a city.
Explanation: The IS NULL clause can be used to 16. Option (C) is correct.
match records having NULL values.
Explanation: read() method in Python is used to
3. Option (B) is correct. read at most n bytes from the file associated with
the given file descriptor. If the end of the file has
Explanation: 199//12 + 156%17 + 2**3*2
been reached while reading bytes from the given
= 16+3+512 file descriptor, Fileobject. read() method will return
= 531 an empty bytes object for all bytes left to be read.
4. Option (A) is correct. 17. Option (A) is correct.
Explanation: The capitalize() function makes the
Explanation: The order of execution of the
first letter of the sentence capital. statements in a program is known as flow of control.
5. Option (D) is correct. The flow of control can be implemented using
control structures. Python supports two types of
Explanation: All of these are data manipulation
control structures—selection and repetition.
language (DML) commands.
18. Option (A) is correct.
6. Option (C) is correct. Explanation: Modules refer to a file containing
Explanation: Infra Red is a line of sight
Python statements and definitions.
communication that uses infra red radiation for
A file containing Python code, for example:
transmission.
example.py, is called a module, and its module
7. There is no output. name would be example.
Explanation: Because variable i is equal to string We use the import keyword to use the module.
value which cannot be used in iteration.
8. Option (B) is correct. Section – B
Explanation: type () method returns class type of
the argument (object) passed as parameter. This
function is mostly used for debugging purpose. 19. (i) (a) Simple mail transfer protocol
(b) Global System for Mobile communication.
9. Option (C) is correct. (ii) A firewall is a security system installed in a computer
Explanation: In creating a list, brackets used are [ ], to prevent unauthorized access and malware into the
not() or { }.
system.
10. Option (B) is correct. OR

Maximum value = 3 Minimum value = 1 (i) VoIP [Voice over Internet Protocol]
11. Option (D) is correct. (ii) IRC [Internet Relay chat]

Explanation: The file transfer protocol (FTP) is used 20.
To=30
for upload and download of files. for K in range(0,To):
12. Option (C) is correct. if k%4==0:

Explanation: Runtime error is when the statement print (K*4)
is correct syntactically, but the interpreter cannot else:
execute it. Runtime errors do not appear until after
print (K+3)
the program starts running or executing.
2 Oswaal CBSE Sample Question Papers, Computer Science, Class-XII

21. def series(x,n): f.close()


OR
if n==1:
return 1/x
def NonZero(L):
nonZeroList=[]
else :
for i in range(len(L)):
return n/x**n + series(x,n-1)
if L(i)!=0:
OR
nonZeroList.append(i)
def factorial(num): return nonZeroList
if num==1:
29. (a) Select * from Cellphone where Type=”4G”
return 1 and cost>10000;
else: (b) Update cellphone set cost= cost +cost*0.2 where
return num*factorial(num-1) type=”5G”;
(c) Alter table cellphone ADD DateofMfg Date;
22. Output
Hi i 30. (i) def PUSH (Arr, value) :
s=[]
Hello
for x in range (0, len(Arr)):
Namaste
if Arr [x] %5==0:
23. (i) Lstnum.insert(3,[12,45,66]) s.append (Arr[x])
(ii) Lstnewnames=sorted(Lstnames,reverse=True) if len(s)==0:
print ("EMPTY Stack")
OR
else:
There is no output because variable i is equal to print(s)
string value which cannot be used in iteration. (ii) def popstack (st): #if stack is empty
24. Describe shop; if len (st) == NULL :
Delete from Shop where Shop_No=255; print (“Underflow”)
else:
OR
l=len (st)
Varchar and Char val=st (1-1)
25. 36 print (val)
st.pop (1-1)

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;

28. def countP(): 32. import csv


def Search(type):
fname = “DIARY.txt”
f=open(“phone.csv”,”r”)
with open (fname,`r’)as f:
fr=csv.reader(f)
l=f.readlines()
for rec in fr:
for line in l: if rec[2]==type:
if l.strip == `P’: print(rec)
print (line) f.close()
Answers 3

Section – E

if rec[0]==cno:
print(rec)
33. (i) f.close()

Finance 35. (i) DDL- ALTER, DROP, CREATE


DML- INSERT, UPDATE
(ii) import MySQLdb
Market Sales db = MySQL.connect(‘localhost’,
’FacAdmin’,'FacAdmin@123’,’XYZHOS’)
cursor=db.cursor()
Legal cursor.execute(“DROP TABLE IF EXISTS
Hospital”)
Star topology should be used.
sql=”””Create Table Hospital(‘Hospital_
(ii) Sales is the most suitable building to place
id’ INT NOTNULL, ‘Hospital_name’
the server because it has maximum no. of
computers. CHAR(50) NOTNULL
‘Bed_Count INT' PRIMARY KEY
(iii) 
Each building should have hub/switch
(‘Hospital_id’)
and modem in case Internal connection is
)”””
required.
cursor.execute(sql)
(iv) 
MAN (Metropolitan Area Network) as this
cursor.close()
network can be carried out in a city network.
db.close()
(v) A modem is used to convert digital signals
OR
produced by computers to analog signals that
can be carried over the telephone networks. (i) Close the cursor

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

You might also like