You are on page 1of 3

ANSWERS

Self Assessment Paper-2


COMPUTER SCIENCE

Section – A 12. Option (B) is correct.


Explanation: These three text streams are
predefined. These streams are implicitly opened
1. False and unoriented at program startup.
Explanation: The default delimiter of a csv file is “,”
(i) stdin: Associated with the standard input stream,
2. Option (C) is correct. used for reading conventional input.
Explanation: To find records that match any one (ii) stdout: Associated with the standard output
value within a set of values, the IN clause can be stream, used for writing conventional output.
used. (iii) stderr: Associated with the standard error stream,
used for writing diagnostic output.
3. Option (B) is correct.
Explanation: 25**0.5 + 12 -165%18 +33//6
13. (b) False
Explanation: An exception in a code execution may
= 5.0 +12 – 3 + 5
terminate the program abnormally.
= 19.0
4. True 14. Option (C) is correct.
Explanation: Only one attribute in a table can be
Explanation: The startsWith function checks

primary key.
whether a string starts with a particular substring
or not. 15. Home page
Explanation: The home page is the 1st page in a
5. Option (B) is correct.
site, just like index of a book.
Explanation: The Drop command belongs to DDL

category. 16. Option (A) is correct.
Explanation: If newline='' is not specified,
6. Option (D) is correct. newlines embedded inside quoted fields will not
Explanation: The Infrared transmission is a short be interpreted correctly, and on platforms that use
range line of sight transmission. \r\n line endings on write an extra \r will be added.
7. 2 It should always be safe to specify newline="\n",
0 since the csv module does its own(universal)
2 newline handling.
4 17. Option (D) is correct.
Explanation: The code checks for digits in the string Explanation: Indexing is used for accessing
and prints them. individual characters within a string. The first
8. Option (A) is correct. character has the index 0 and the last character has
Explanation: The expression is evaluated the index n-1 where n is the length of the string.
according to the operator hierarchy. i.e first NOT The negative indexing ranges from -n to -1.
will be evaluated then AND and then OR. Strings in Python are immutable, i.e., a string
cannot be changed after it is created.
9. Option (B) is correct.
Explanation: Option b is invalid because ‘A’ is an 18. Option (A) is correct.
invalid mode in Python. Explanation: The concatenation operator + when
‘w’ Opens a file for write mode. used with two lists, joins them. The + operator
‘a’ Opens a file for append mode when used with lists requires that both operands
‘w+’ Opens a file for both writing and reading must be of list types. You cannot add any other
10. Option (i) is correct. value to a list.
Example:
PICK maxval = 3 minval = 0
>>>list1=[1,2,3]
11. Option (A) is correct. >>>list2 = [4,5,6]

Explanation: Bluetooth connects personal devices >>>list1 +list2
in a short range. [1,2,3,4,5,6]
2 Oswaal CBSE Sample Question Papers, Computer Science, Class-XII

Section – B
19. (i) (a) TCP/IP : Transmission control protocol / print ("sum of squares of first two
and last two digits is", sum)
Internet protocol return
(b) CDMA : Code division multiple access OR
(ii) The process of uploading web pages to a public server a = 5
is called web hosting. b = 9
OR def swap(c,d):
(i) Domain name – income.in return d,c
URL-http://www.income.in/home.aboutus.html a, b = swap(a,b)
(ii) Popular web browsers: Google Chrome, Mozilla 22. 250#150
Firefox, Internet Explorer, etc 250#100
130#100
20.
c=dict()
n=int(input("Enter total number")) 23. (i) empdict["Email"]="jack@gmail.com"
(ii) print(t[-3])
i=1
OR
while i<=n: [[[1, 2, 3, 4, 5], [6, 7, 27]], 50]
a=input("enter place") []
b=int(input("Enter number"))
24. Create table toys(ToyId integer, Toyname
c[a]=b
varchar(20), Category varchar(1), Price float(8,2),
i=i+1 Vendor varchar(20));
print ("place","\t","number") Describe toys;
for i in c: OR
print (i,"\t",c[i]) Degree = 8 (No. of columns)
Cardinality = 8 – 2 = 6 (no. of rows)
21. def calcsquareDigits(num):
sum=((num%100)**2)+((int(num/100))**2) 25. [ ] & [25, 20, 15, 10]

Section – C
26. [[[6, 2, 3, 17, 5], [6, 7, 8]], 200]
[[[6, 2, 3, 17, 5], [6, 7, 8]], 200]
[[6, 2, 3, 17, 5]]
27. (i) 38000 1200
(ii) 1075000
(iii) 1004 CAR GPS SYSTEM 50 21500 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1005 PEN DRIVE 32 GB 600 1200 STOREHOME T03
28. def
reverse(): (c) Update STUDENTS Set Address=”C-97” where
file=open("myfile.txt","r") ADDRESS IS NULL;
text=file.readlines() 30. def pushStack(stack,ch):
file.close() stack.append(ch)
n=len(text) top=len(stack)–1
file=open("myfile.txt","w") return
for i in range (n–1,–1,–1): def popStack(stack):
file.writeline(text[i]) if isEmpty(stack):
file.close() return
OR else:
def reverse(): top=len(stack)–1
file=open("Poem.txt","r") for a in range(top–1,–1,–1):
text=file.readlines() print(stack[a])
file.close() stk=[]
line=len(text) top=none
for i in range (line–1,–1,–1): str=input("Enter a string")
print(text[i]) while a in str:
29. (a) Select count(distinct RNO) from Students; pushStack(stk,a)
(b) Select Name , Class, , Address from Students where print("Reverse")
name like “%EE%” order by Sec Desc; popStack(stk)
Answers 3

Section – D loc= input(“Enter tour location :”)


trec.append([t,tn,tr,pr,loc,trec])
31. (i) Alter table Worker Modify NAME varchar(40); fw.writerow(trec)
(ii) Select W.Name , W.Design, P.PAY + f.close()
P.ALLOWANCE as “Totalpay” from WORKER W , OR
PAYLEVEL P where W.PLEVEL= P.PLEVEL; (i) EOL(END OF LINE)
(iii) Select W.Name , W.DOB, P.PAY + (ii) import pickle
P.ALLOWANCE as “Pay” from WORKER W , def Update(gid):
PAYLEVEL P where W.PLEVEL= P.PLEVEL and
f=open(“Games.dat”,”r”)
W.DESIGN=”Supervisor”;
(iv) Select count(*) from WORKER where glst=pickle.load(f)
Design=”Operator”; newrec=[]
32. import csv for rec in glst:
def getBook(Pub) : if rec[0]==gid:
f=open(“Books.csv”,”r”) gn=input (“New game name
fr=csv.reader(f) :”)
for rec in fr: tp= input (“New game
if rec[2]==Pub: type :”)
print(rec) pm= input (“New game
prizemoney :”)
f.close()
newrec.append([gid,gn,tp,pm])

Section – E
else :
newrec.append(rec)
f.close()
33. (i)  _TOWN can house the server as it has the
B
f=open(“Games.dat”,”w”)
maximum no. of computers.
pickle.dump(newrec,f)
(ii) 
Optical fibre cable is the best for this star
topology. f.close()
VILLAGE 3 VILLAGE 2 35. (i) In SQL, HAVING clause is used to filter the
1.5 KM 1 KM output obtained by the GROUP BY clause based on
specific condition.
B_TOWN
(ii) import MySQLdb
db = MySQLdb.connect(‘localhost’,
‘HRMan’, ‘HRManexe@pwd’, ‘Employee’)
2 KM
cursor = db.cursor()
VILLAGE 1 sql = “Delete from Employee where
AGE>’%d’/(60)
(iii) Switch try:
(iv) VoIP db.execute(sql)
(v) MAN (Metropolitan Area Network) will be db.commit()
formed as network would span within a city. except:
34. (i) The writerow() function writes a single record or db.rollback()
db.close()
a single list carrying a record, to a csv file.
OR
The writerows() function writes multiple records to
(i) 255 bytes
a csv file ,which may exist together as a nested list.
(ii) import MySQLdb
(ii) Program : db = MySQLdb.connect(‘localhost’, ‘HRMan’,
import csv ‘HRManexe@pwd’, ‘Employee’)
def addMore(): cursor = db.cursor()
f=open(“Tour.dat”,”a”) sql = “Delete from Employee where AGE>’%d’/
trec=[] (60)
fw=csv.writer(f) try:
db.execute(sql)
t=input(“Enter tour id :”)
db.commit()
tn= input(“Enter tour name :”) except:
tr=int(input(“Enter number of db.rollback()
tourists :”)) db.close()
pr= float(input(“Enter tour price:”))
qqq

You might also like