Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

KENDRI

YAVI
DYALAYASANGATHANJAI
PURREGI
ON
Sampl
eQuest
ionPaper(
Ter
m-I
)
Class :XII Ti
meAll
owed :90Mi
nut
es
Subject :(083)Comput
erSci
ence Maxi
mum Marks:35

Gener
ali
nst
ruct
ions:
Thepaperisdi
vi
dedinto3Secti
ons-A,
BandC.
Secti
onA,consi
stsofQuest
ion1to25andstudentneedtoattempt20quest
ions.
Secti
onB,consi
stsofQuest
ionnumber26t
o49andst udentneedt
oatt
empt20quest i
ons.
Secti
onC,consi
stsofQuest
ionnumber50t
o55andst udentneedt
oattempt5quest
ions.
All
questi
onscarr
yequalmarks(0.
77markperquesti
on).

Secti
on–A
Sect
ionAconsi
stsof25questi
ons,
att
emptany20quest
ions
1. Chooseoddoneout:
- A.1
A.except B.2
B.wi t
h C.3
C.Import D.4
D.else 6. Tor
eadt
her
emai
ningl
i
nesoft
hef
il
efr
om a
fi
l
e
2. Whatwi l
lbetheout
putoft
hef
oll
owi
ngcode obj
ectinfi
le,
weuse_
segment ? A.i
nfi
le.r
ead(2)
l
=['
A','
a'
,'
Aa'
,'
aA'
] B.i
nfi
le.r
ead()
pri
nt(max(l
)) C.i
nfi
le.r
eadli
ne()
A.'aA' D.i
nfi
le.r
eadli
nes()
B.'
A',
C.'a' 7. Whichi
snotast
ri
ngoutoft
hef
oll
owi
ngs:
-
D.'Aa' A.‘
55’
B.“
X.Y”
3. Whi
choneoft
hef
oll
owi
ngsi
slogi
caloper
ator
: C.“
Hell
o1”
- D.Noneoft
heabove
A.exponent
B.modulus 8. Namet hemodulewhichwi
l
lbeneededt
ouse
C.and t
hef unct
ionmax():-
D.fl
oordivi
sion A.mat h
B.random
4. Whichofthefol l
owingstatement (
s)i s/ar
etrue? C.stat
A.Wheny ouopenaf il
ef orreading,ifthef il
e D.Nomodul erequi
red
doesnotexist
, anerroroccurs
B.Wheny ouopenaf i
leforwr i
ting,ifthef il
e 9. Whichcommandwecanuset or emov e
doesnotexist
, anewf il
eiscreated st
ri
ng“ hel
lo”from l
ist1,
Given,l
ist1=[
“hel
lo”
]
C.Wheny ouopenaf i
leforwrit
ing,ifthefil
e A.l
ist
1.remov e(“
hell
o”)
exi
sts,theexisti
ngf il
eisov erwritt
enwi tht he B.l
ist
1.pop(l
ist1.
index('
hel
l
o'))
newf i
l
e C.Botha&b
D.Allofthement ioned D.Noneoft hese

5. Whati
sthelengt
hoft
hegi
vent
upl
e? 10. Avar
iabl
edeclar
ed/
defi
nedout
sideaspeci
fi
c
t
1=(1,
2,
(3,
4,
5)) f
unct
ionisknownas:-

1|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
A.Local var
iable
B.Specif
icvariable 18. Numberofl
i
nesr
equi
redf
oroner
ecor
dina
C.GlobalVar i
able csv
D.Noneoft heabov e fi
l
e:
11. Whichoft hefoll
owi ngisnotafunct
ionoft
upl
e? A.Itdependsont hesi
zeoft
her
ecor
d
A. updat e() B.2
B.i ndex() C.1
C.l en() D.Noneoft hese
D.count ()
12. …………………f unct i
oni susedtoknowthe 19. Whichoft hefol
l
owingwil
lrai
seanerrori
fthe
posit
ionoffilepointerinafi
le:
- gi
venkeyi snotfoundi
nthedict
ionar
y?
A.get_pos() A.delstatement
B.tel
l() B.pop()
C.seek() C.geti
tem( )
D.positi
on() D.all
oft hese

13. Whatist he deli


mi t
erinfol
l
owing csv f
il
e'
: 20. I
nfi
l
ehandl
i
ng,whatdoest
hist
erm means“
r,
f=open(‘
abc.csv’
,
del
i
mit
er=’
\n’
): a”?
A.Tabspace A.read,append
B.Comma B.append,read
C.NewLi neChar acter C.writ
e,append
D.BlankSpace D.noneoft hement
ioned

14. Writetheout
putofthef
ollowi
ng: 21. Whichofthef oll
owingstatementi
strue:
a=(1,2,3,
2,3,4,
5) A.csvi
snotav ai
lableinal
phanumeri
c
pri
nt(min(
a)+max(a)+a.count
(2)
) B.csvf
il
eisf astertohandle
A.13 C.csvf
il
ei ssmal lerinsi
ze
B.6 D.csvi
susedf orlargedatatr
ansf
er
C.8
D.Error 22. Whatisthemeaningof‘
r+b’
inbi
nar
ymode?
A.wri
teandread
15. Whi
choft hef
oll
owingcont
entcanbe B.r
eadonly
r
epr
esentedbyabinaryf
il
e? C.r
eadandwr i
te
A.image D.wri
teonly
B.video
C.audio 23. Theread( )met hodretur
ns
D.Alloftheabove A.St
ring
B.ALi stofintegers
16. I
nwhi choft
hefor
mattheendoft
hel
i
nei
s C.Alistofchar acter
s
denot
edby‘\n’
and‘\
r’
? D.ALi stofLines
A.Binary
B.Text 24. Inwi
ndowscsvf i
lecannotbeopenedwi
th:
C.Both A.MicrosoftExcel
D.Noneofabove B.Microsoftword
C.AcrobatReader
17. Whi chmethodi
susedf
orwr
it
ingdat
ainbi
nar
y D.Notepad
fi
l
e?
A.dump() 25. Del
i
miteri
ncsvf
il
emaybechanged.
B.l oad(
) A.True B.False
C.seek() C.BothTr
ueandFal
se D.None
D.tell
()

2|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
Secti
on–B
Sect
ionBconsi
stsof24quest
ions,
att
emptany20quest
ions.
26.Wr i
tetheout putoft
hef
oll
owi
ng. D.0123
A=t uple(“
Py t
hon”)
pri
nt(A) 31.Whi ch st at
ementdoesnotshow anyer
ror
A.(python) aft
erexecut ion?GivenL=[
1,2,
3,
4]
B.(“Python”) A.pri
nt(L+L)
C.(‘
P’ ,‘
y’,‘
t’,‘
h’,‘
o’,‘
n’
) B.pri
nt(L* L)
D.Noneoft heabov e C.print(L-L)
D.Alloft hement i
oned
27.
Assumet hecont entoftextf
il
e,'
student
.t
xt'
is:
Rameshi sstudent
Radhai sgir
l
KVS 32.
Whatwi llbe t he outputoff oll
owing code:
i
mpor tpi ckle
Jai
pur
Emp_ Names=[ ‘Umesh’,‘
Sapan’
,‘
Mukesh’
,‘
Har
ish’
,‘
Nav
al’
]
Whatwi ll
bet hedatat ypeofdata_
rec? li
st1=[]
myf i
l
e=open( "
student.
t xt
") foriinr ange( -
1,-
6,-2):
data_rec=my fi
le.r
eadli
nes( ) l
ist1.append( Emp_ Names[ i])
myf i
l
e.close() withopen( ‘
emp. dat’,‘
wb’)asf out:
A.stri
ng pickle. dump(list1,
fout)
B.l
ist withopen( ‘
emp. dat’,‘
rb’
)asf i
n:
C.tuple newl ist=pi
ckle.load(fi
n)
D.dictionary pr
int(newl i
st)

28.whi chcommandweusecaneuseTor
emov
e A.[
‘Umesh’
,‘Sapan’
,‘
Mukesh’
,‘Har
ish’
,‘
Nav
al’
]
str
ing“ hel
lo”from list1, B.[

Umesh’,‘Sapan’
,‘
Mukesh’
]
Given,li
st1=[“hell
o”] C.[
‘Nav
al’
,‘
Mukesh’,‘Umesh’
]
A.list1.r
emov e(“
hello”) D.[
‘Nav
al’
,‘Umesh’,‘
Mukesh’
]
B.li
st1.pop(li
st 1.
index('
hel
l
o')
)
C.botha&b
D.noneoft hese

29.Whi choft hefol


lowi
ngi
snotadecl
arat
ionof
thedicti
onar y
?
A.{1:‘A’
, 2:‘
B’} 33.Whichst atement (
s)aretrueaboutthepickl
e
B.dict([
[1,”
A”],
[
2,”
B”]
]) moduleindat afil
ehandling?
C.{1,”
A” ,
2”B”} A.Iti
susedf orser i
ali
zati
onanddeseri
ali
zat
ionof
D.{} anypythonobj ectstr
ucture
B.I
tprovidestwomet hodsdump()andload()
C.Both(a)and( b)
30.Wr i
tetheoutputof - D.Itpr
ovidestwomet hodsseek()andtell
()
d={0:'zero'
,1:
'
one',
2:'t
wo',3:
'
three'
}
foriind:
34.I
denti
fycorrectoutput
print(i
,end='')
deffun3(a,
b,c):
A.{0:'zero'
,
1:'
one',
2:'
two',
3:'
thr
ee'} r
eturna+1,b+2,
c+3
B.'zero',
'
one',
't
wo','
thr
ee' t=f
un3(10,20,30)
C.Er r
or pri
nt(t
)

3|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
A.11,22,
33 c)5@50
B.112233 d)100@10@
C.(11,22,33)
D.(112233) 38.Whatwi l
lbe t he possi ble out putoft
he
foll
owi ngcode?
35.Ev
aluat
etheexpr
essi
ongi
venbel
owi
fA=16 i
mpor trandom
andB=15. List=[
’Delhi’
,’
Mumbai ’
,’Chennai ’
,
’Kolkata’]
foryinr ange( 4)
:
A%B/
/A x=random. r
andint(1,3)
print(
List[
x],end=’
#’)
A.0.
0 A.Delhi#Mumbai #Chennai #Kolkata#
B.0 B.Mumbai #Chennai#Kolkat a#Mumbai #
C.1.
0 C.Mumbai #Mumbai #Mumbai #Del hi#
D.1 D.Mumbai #Mumbai #Chennai #Mumbai
36.Whatwi l
lbet heout putofthef
oll
owi
ngpy
thon 39.Predictt
heoutputofthef
oll
owi
ngcode(
A)
code: deffun3(num1,num2):
defA_func( x=10,y=20): forxi nr
ange(num1,
num2):
x=x+1 ifx%4==0:
y =y-2 pr
int
(x,
end=’‘
)
return(x+y) fun3(10,20)
pri
nt(
A_ func(5),
A_func(
)) a.10121620
A.24,29 b.1216
B.15,20 c.121620
C.20,30 d.16
D.25,30

40.Consi deringt hefol


lowingfuncti
on/met hodin
py thon whi ch r ead lines from a t ext fi
le
37.Whatwi llbetheoutputoft
hef
oll
owi
ng “INDI A.TXT” ,tof i
ndanddi spl
ayt heoccurrenceof
py t
honcode: thewor d“ I
ndi a”.Findt hemissingstatementi n
val =100 followi ngcode:
defdi splay
(N): defcount wor d():
global val
f=open( "
INDI A.TXT",'r
')
val =50
i
fN%14==0: count =0
val=val+N dat a=_ ___
_ _
_ ____
else: wor d=dat a.spl i
t()
val=val-N fori inwor d:
print(
v al
,end="
@" ) ifi.l
ower ()=='i
ndi a'
:
display (
40) count =count +1
print(
v al
)
pr i
nt("noofwor ds=",
count)
a)100@10
b)50@5 f.close( )

4|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
(A)f.r
ead( ) Humpt yDumpt ysatonawal l
(B)f.r
eadl i
ne( ) Humpt yDumpt yhadagr eatf all
(C)f.r
eadl i
nes Alltheki ng'shorsesandal ltheki ng'
smen
(D)f.wr i
te( ) Coul dn'tputHumpt ytogetheragai n
41.Consi dert hecodegi venbelow andI
dent
if
y Poem i sgoodbutdonotl ike
Whichmessagewi l
lneverbepri
nted Consi deringt heabov ef i
l
e,whatout putwil
lbe
defpr og( name) : produced by t
he fol
lowing code?
forxi nname:
f=open( "new.txt
",
'r'
)
i
fx. isalpha():
print(
“alphabet”) a=f.readline()
eli
fx. isdigi
t()
: b=f.read(4)
print(
“digi
t”) c=f.r
eadl ine()
eli
fx. isupper(): d=f.readline()
print(
“upper”) pri
nt( c)
else: f.
close( )
print(
“allt
hebest ”)
(A)agr eatfall
prog(“vishal 123@gmai l
.com”)
(B)tyDumpt ysatonawal l
A.alphabet (C)Dumpt ysatona
B. di
git (D)Humpt ytogetheragai
n
C.upper 44.Ident ifyt
heOut putforthebel owcode:
D.allt
hebest z=5
defA_ f
unc( x=10, y
=20):
x=x+z
y=y -z
return( x+y)
pri
nt( A_func(5),
A_ f
unc()
)
A)2025
B)2530
C)1020
D)1525

42.Youhav egivenaf i
le'st
u.t
xt' 45.Thereadli
nes()methodret
urns_
___
___
___
__
mykvi sbesti nthewor l
d.iam abestst
udent
. A.ast r
ing
ili
kecomput er. B.al i
stofl
ines
Whatwi llbet heout putoft hefol
lowi
ngcode? C.listofsi
nglecharact
ers
my f
ile=open( "stu.
txt
") D.al i
stofint
egers
str=my file.readli
nes(
)
pri
nt(str
)
my f
ile.
close( ) 46.Readt hecodegi venbel
ow andanswert he
(A)readf i
r stli
ne question:
f=open(“sample.t
xt”
,’
w’)
(B)readent i
ref i
l
e
f.wri
te(“
Mor ni
ng”)
(C)readsecondf il
e
f.cl
ose()
(D)Noneofabov e
I
ft hef i
l
econt ai
ns“Good”befor
eexecuti
on,what
43.The f
il
e“new.
txt
” cont
ains t
he f
oll
owi
ng wi l
lbet hecontentsofthefi
l
eaf t
erexecut
ionof
cont
ent
: thiscode?
mypoem A.GoodMor ni
ng
5|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
B.Good Whatwi l
lbethedatatypeofdat
a_r
ec?
C.Morni
ng myfi
le=open( "
student
.txt
")
D.Noneofthese dat
a_rec=my fi
le.r
ead(
)
myfi
le.
close(
)
47.Toopenaf il
eMy f
il
e.txt,whichisstor
edinD A.stri
ng
Dri
veunderfolderCS, f
orREADI NG, wecanuse B.li
st
A.F=open(
"d:\
CS\ My fi
l
e.txt",
"r
w")
C.tuple
B.F=open(
fi
le="d:
\CS\ My fi
le.
txt"
,"
wr")
C.F=open(
r"d:
\CS\ Myfil
e.txt"
,"
r") D.di
ctionar
y
D.F=open(
"d:\
My folder\\
My f
il
e.t
xt",
"w"
)
49.Whichofthef oll
owi
ngst
atementwi
l
lret
urn
anerr
or?T1isatuple.
48.Assumethecontentoft
extf
il
e,'
student
.t
xt'
is:
A.T1+(23)
Rameshisstudent
B.T1+[3]
Radhaisgi
rl C.Bot
hoftheabove
KVS D.Noneoftheabove
Jai
pur

Sect
ion–C
Sect
ionCconsi
stsof06quest
ions,
att
emptany05quest
ions.
Bhav eshisl earni
ngt owor kwithBinaryf i
l
esi n i
mpor t__________
_ #St
atement-
1
Py t
honusi ng apr ocessknownasPi ckli
ng/Un- L1=list(
)
pickl
ing.HisComput erSci
enceteachergivenhim foriinr ange(4):
thefollowi
ngi ncompl et
ecode,whichiscreati
nga L.append( i
+i)
Binaryf i
le namelyRecor d.datand then opens, f1=open( “Record.dat
”,_
___
_)#Stat
ement-2
readsanddi splaysthecontentoft
hiscreatedfil
e. ___________(L1,
f1) #St
atement
-3
6|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22
f1.
close(
) C.pi
ckle.
dump(
)
f2=open(“
Recor
d.dat
”,“
rb”) D.wri
teli
ne(
)
L2=_____
____
___
(f2) #St
atement
-4
f2.
______
____
__ #St
atement
-5 53.Whichf uncti
ontobeusedi
nSt
atement
-4t
o
pri
nt(L2) #St
atement
-6 readthedatafrom t
hef
il
e.
A.load(
)
50. Whi ch modul
e shoul
d be i
mpor
ted i
n B.readl
ine()
Statement-
1. C.readl
ines()
A.pickl
e D.pickl
e.l
oad()
B.csv
C.fi
le 54.Whichfunct
iontobeusedi
nSt
atement
-5t
o
D.text cl
osethefi
leRecor
d.dat
A.dump()
51.Whi
chfi
lemodetobepassedt
owr
it
edat
ain B.l
oad()
fi
l
einSt
atement
-2. C.exi
t(
)
D.cl
ose()
A.w+
B.w 55.Theoutputaf
terexecut
ingSt
atement
-6wi
l
lbe
C.wb –
D.a A.0246
52.Whatshoul
dbewr
it
teni
nSt
atement
-3t
owr
it
e B.{0,
2,4,6}
dataont
othefi
le. C.[0,
2,4,6
A.dump() D.(0,2,
4,6)
B.wri
te(
)

0-
O-o-BestofLuck–o-
O-0

7|
KVS–Regi
onal
Off
ice,
JAI
PUR|
Sessi
on2021-
22

You might also like