Sample Paper Cs Xii
Sample Paper Cs Xii
Section -B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions from thís section. Choose the
best possible option.
26What will be the output of following Python Code:
if 5>2 or 8<5 and 0 :
print(Hello")
else:
print("Welcome")
a) Error b)Hello c) Welcome d) HelloWelcome
27What will be the output of following Python Code:
X,Y=10,20
Y,Y,Y=Y+2, X+5, Y-2
print(Y)
a) 20 b) 15 c)-18 d) 22
28What willbe the output of following Python Code:
P,S=1,0
for X in range(-5,15,5):
P*=X
S+-X
else:
print(P, " , S)
a) 10#5 b) 10#0 c) 0#10 d) S#10
291 Identify the output of the following Python statements.
LIH6,4,2,9,7]
LI[3:]= 100"
(a) [6,4,2,9,7, 100] (b) [6,4,2,100] (c) [6,4,2,1,0,0] (d) [6,4,2, 1','0', 0']
30 What will be the output of following Python Code:
import random as rd
So,
S ,S2,5)s6
high=4
Guess=rd.randrange(high) +50
for C in range(Guess, 56):
print(C,end="#")
b) 54 # 53 # 54 #55#
a) 50 # 5l# 52 # 53 # 54 # 55#
c) 53 # 54 # 55 # 56 # d) 51 #52 # 53 # 54 #55
31What will be the output of following Python Code:
data=|10,"ram",20,"'sham",30,"'anil"|
data.append("Sunil")
data|2]="Raj"
data.pop)
del data|1]
data<-1|="Magie"
print(data)
a) [10, 'Ram, 'sham, 30,'Sunil)] b-(10,'Raj', 'sham, 30, 'Magic]
[10, 'Magic', 'sham, 30, 'Sunil'] d) [10, 'Ram', 'sham', 30, Magic])
32 What will be the output of following Python Code:
def evenodd(num):
for iin range(len(num):
if num[i|%2--0:
num[il/=2
else:
num[i]*=2
return num
#main-coding
numbers=[10,15,20,25|]
print(evenodd(numbers) #function call
a) [5, 30, 10, 25] b)-{5.0, 30, 10.0, 50]
c) [20.0, 7.5, 40.0, 12.5] d) [20, 15, 40, 12.5]
33 What will be the output of following Python Code:
def convert(name):
N=!
for k in name:
if k.isupper):
N=N+k.lower)
elif k.islower):
N=N+k.upper)
else:
N=N+k
print(N)
#main-coding
convert("Term-1#EXAM")
aytERM-1#exam b) Term-1#EXAM
) exam-1# tERM d) #EXAM Term-1
34 What will be the output of following Python Code:
G=10
def fun10:
global G
G=20
print(G, end="*")
G=G+10
fun1() #call to funl
print(G)
a) 10*20 by20*30 c) 20*20 d) 10*10
Suppose the eontent of Mfle u s
Humpty LDumpty sat on a wall
IHumpty Dumpty had ayeatfoll
Allthe king's horses and all the kingsen
Couldn't put Humpty togethe ogin
What will be the output of he following oode?
myfile open("Myfile.txt")
record myfile.readlínes)
print(len(record)
myfile.close)
a)4 b) 5 c)6
File2.write(word+« ")
Filel.close()
File2.close0
a) God One GOD God by God Øne God you
c)God One GOD God you d) God GOD God
40<| Raj has written following program to copy
story.txt file data into fle
complete the program by choosing correct option to fill in blank. kahani.txt. Help Raj to
# Program tocopy Story.txt file into new file
Kahni.txt
filel=open("story.txt","r")
file2=open(" kahani.txt","w")
data=filel.read)
# towrite data in kahani.txt
filel.close)
file2.close)
print("File copied")
a) filel.writedata() b) file2.writedata( ) c) filel.write(data) d) file2.write (data)
417 Syntax of seek function in Python is
myfile.seek(offset,
object. What is the default value of reference point? reference point) where myfile is the file
b)1 c) 2 d) 3
42 The content of text file
INSTITUTE.TXT is :
KVS is a great organization
What will be the content of
INSTITUTE.TXT after execution of following Python code:
filel=open("INSTITUTE.
file.write("of India") TXT","w'")
filel.close(0
a) KVS is a great organization of India
c) KVS is a great organization b)KVS is a great organization of World
d)of India
Raj is trying to write an object objl =(1,2,3,4,5) on a
binary file "test.dat". Consider the following
Page 6 of 2
code written by him.
import piekle
objl = (1,2,3,4,5)
myfile open("test.dat",'wb')
pickle. NStatement 1
myfile.clese( )
Identify the missing code in Statement 1.
a) dump(myfile,objl) bydump(obj l, myfile)
c) write(objl,myfile) d) load(myfile,objl)
44 The content of binary file STUDENT. DATis :
{'rno': 1, 'name':'raja', 'marks' 95.5)
'marks': 78.0)
{'rno : 2, 'name': ram singh', 'marks ': 68.0)
('rno': 3, 'name:'sonia',
'marks' : 85.5)
{'rno' : 4, 'name':'rajesh',
'marks' : 48.0)
{'rno' : 5, 'name':'raj singh',