You are on page 1of 17

1.

sel
ectthel
i
stcompr ehensi
oncodeequi
val
entt
othebel
owscr
ipt
.
sum=[]
forxi
nrange(1,
3):
foryi
nr ange(3,6)
:
sum.append(x+y
)

1.
sum=[x+yf orxinrange(1,
3)foryi nrange(
3,6)]
2.
sum=forxinrange(1,
3)foryinr ange(3,
6)printx+y]
3.
sum=[ret
urnx+yf oryinrange(1,3)forxinr
ange( 3,
6)]
4.
sum=[forxinrange(1,
3)foryinr ange(3,
6)returnx+y]

2.whi
chf
unct
ioni
susedt
oreadt
wochar
act
ersf
rom af
il
eobj
ecti
nfi
l
e?

a.i
nfi
le.
readl
ine(2)
b.i
nfi
le.
read(
2)
c.i
nfi
l
e.read(
)
d.i
nfi
le.
readl
ines(2)

3.whi
chf
unct
ioni
susedt
owr
it
ethedat
aint
hebi
nar
yfor
mat
?

a.dump
b.wri
te
c.out
put
d.al
loftheabov
e

4.
whi
chcol
l
ect
ioni
susedt
ost
oreuni
quev
alues?

l
i
st/
dict
/tupl
e/set

5.
ident
if
ytheout
putpr
int
((2,
4)+(
6,8)
)

a.(2,4,6,
8)
b.error
c.{4,6}
d.{(2,4),
(6,
8)}

4.className( obj
ect)
deffi
rst(
):
pri
nt(
"Iam cal
led"
)
defsecond():
pri
nt(
"Igotcal
led"
)
obj=Name()
Name. f
ir
st(obj
)

a.unboundmet hodcal
l
b.boundedmet hodcal
l
c.i
ncorrectobj
ectdecl
arat
ion
d.al
ltheabov e

5.
whi
chi
sappr
opr
iat
etouset
hest
ati
cmet
hodi
nacl
ass?

a.
toaccesstheatt
ri
buteoftheinst
ance
b.t
oinstant
iat
etheclassbasedonthegiv
enpar
amet
er
c.
toper
formt
heacti
onr
elev
antt
otheclasswit
houti
nst
ant
iat
ingt
hecl
ass
d.t
oaccesst
hest
ati
cmembersoftheclass

6.whi
chf
unct
iondi
spl
aysaf
il
edi
alogf
oropeni
nganexi
sti
ngf
il
e?

a.t
mpf
il
e=askopenfil
ename()
b.t
mpf
il
e=openfi
lename( )
c.t
mpf
il
e=saveasfi
lename()
d.t
mpf
il
e=asksaveasfil
ename(
)

7.defdemo():
t
ry:
pr
int
(1)
fi
nal
l
y:
pr
int
(2)
demo(
)

a.
2
b.
12
c.
1

7.Onwhatcondi
ti
onf
inal
l
ybl
ockget
sexecut
ed?

1.
onspecif
iccondi
ti
on
2.
onexcepti
ons
3.
onerror
s
4.
alway
s

8.sel
ectt
hecor
rectopt
ion

a.noneoftheli
stedopt
ions
b.auserdefi
nedexcept
ioncanbecreat
edbyder
ivi
ngacl
assf
rom err
orcl
ass.
c.cust
om excepti
onsareunav
ail
abl
einpyt
hon
d.auserdefi
nedexcept
ioncanbecreat
edbyder
ivi
ngacl
assf
rom except
ioncl
ass.

9.sel
ectt
hecodesni
ppett
hatdi
vi
debyzer
oer
rorwi
ther
rormessage"numbercannotbedi
vi
dedwi
th
zero"

a.t
ry:1/except:
rai
se
b.t
ry:1/exceptaxe: pr
int(e)
c.t
ry:
1/exceptZer oDivi
sionError
:print
("
numbercannotbediv
idedwi
thzer
o")
d.t
ry:1/exceptValueError
: pr
int(
("numbercannotbediv
idedwit
hzer
o")

10.i
denti
fyt
heoutput
-
forii
n[1,
0]:
pri
nt(
i+1)

a.1
b.21
c.11
11.
ident
if
ytheout
put

y=["
test
",'
Done’]
foriiny:
i
.upper
()
pri
nt(y)

a.['
test
',
'
Done']
b.['
TEST',
'DONE']
c.noneoft hel
ist
edopt
ions
d.[None,None]

12.
sel
ectt
hecor
rectmat
ch

1._
_ i
ter__2.next
a.met hodthatiscal
l
edai ni
ti
ali
zat
ionofani
terat
or
b.theiterat
ornextmethodretur
nsthenextv
aluefort
hei
ter
abl
e.

a.1-a2-
b
b.*
**
b.*
***
d.*
**

13.numbers=[
2,4,
6,
8,1]
newnumbers=tuple(
map(
lambdax:
x*x,
number
s))
pri
nt(
newnumbers)

a.(
4,16,
36,64,
1)
b.(
2,4,
6,8,
1)
c.[
2,4,
6,
8,1]
d.[
4,16,
36,64,
1]

14.
whati
stheo/
p

defstri
ng_ reverse(st
r1):
str
2=" "
i
ndex=l en(str1)
whileindex>0:
str2+=st r1[i
ndex-1]
i
ndex=i ndex-1
ret
urnst r2
pri
nt(str
ing_ r
ev er
se('
5678ABCD'
))

a.5678ABCD
b.8765DCBA
c.DCBA8765
d.noneoftheabov
e

14.
whi
choft
hef
oll
owi
ngcodeusesi
nher
it
ance?

a.cl
assHel
l
o:Passcl
asswor
ld(
Hel
l
o):
Pass
b.cl
assHel
lo:
Pass
c.cl
assHel
lo:
PassclassTest
:Passcl
assWor
ld(
Hel
l
o,Test
):
Pass
d.noneoft
heabove

15.
codesni
ppet

cl
assCompany :
def__i
nit__(
self,
name,empnum) :
sel
f.name=name
sel
f.empnum =empnum
defmy func(sel
f):
pri
nt("Wel
comet o"+self.
name+'
'+sel
f.
empnum)
p1=Company ("
Cognizant
",
"12345"
)
p1.myfunc()

a.Welcomet oCognizant
b.Syntaxerr
or,t
hisprogram wi
l
lnotr
un
c.Welcomet oCognizant12345
d.Cognizant12345

16.codesni
ppet

defcoverFuncti
on()
:
gl
obal a
a=4
definnerFunct
ion(
):
gl
obal a
a=5
pri
nt('
a=',
a)
a=6
coverFuncti
on()
pri
nt('
a='
,a)

a.a=5a=4
b.a=5
c.a=6
d.a=4

17.
Listt
her
etur
nty
peoff
ormatf
unct
iononst
ri
ngs

a.boolean
b.str
ing
c.err
or
d.int
eger

18.
tr
ueorf
alse

out
putoft
hebel
owst
atementi
s"Py
thon"

st
r_v
ari
able="Hel
loPyt
hon"
pr
int
(st
r_v
ariabl
e[6:
11]
)
sel
ectone

a.t
rue
b.f
alse

19.
whi
chkey
wor
disusedatt
hebegi
nni
ngoft
hecl
assdef
ini
ti
on

a.pass
b.class
c.
_ _i
nit
__
d.def

20.o/
poft
hecode

i
mportOrder
edDict/from coll
ect
ionsi
mpor
tOr
der
edDi
ct
my_st
ri
ng1="Wel
come1"
pr
int
(my_st
ri
ng1)
my_st
ri
ng2="Welcome2"
pr
int
(my_st
ri
ng2)
my_st
ri
ng3="Wel
come4"
pr
int
(my_st
ri
ng3)
my_st
ri
ng4=""
"WelcomeAll
"""

a.Welcome1Wel
come2Wel
come4Wel
comeAl
l
b.Er
ror
c.Welcome1Wel
come2Wel
come4
d.Welcome1Wel
come2

21.
chooset
hecor
rectopt
ion

cl
asspy
_Arr
aysum:
deftwoSum(self
,numbers,t
otal
):
lookup={}
iftot
al-
num inlookup:
retur
n(l
ookup[t
otal
-num]
+1,
i
+1)
lookup[
num] =i

pr
int
("
Number
1=%d"
%py
_Ar
ray
Sum(
).
twoSum(
(3,
1,
4,
5,
2,
7),
6))

out
put
:Number1=2,
Number
2=4

Sel
ectone

a.noneoft heli
sted
b.whilei,
num inenumerate(number
s);
c.i
fi,num inenumer at
e(numbers)
;
d.fori
, num i
nenumer ate(
numbers);
22.Letat
upl
eval
uecont
ains5el
ement
s,howt
osett
hir
del
ementoft
het
upl
eto'
i
ndi
a'

a.deftest
b.test[
3]='
i
ndi
a'
c.elementsoft
het
upl
eremai
nunchanged
d.test[
2]='
i
ndi
a'

22.
ident
if
ytheout
put

i
nteger=[1,
2,
3,4,
5,
6,
7,
8,
9]
pr
int(
integer
[:
:3]
)

a.[
1,3,
5,
7,
9]
b.[
1,3,
5]
c.[
1,3,
5,
7]
d.[
1,4,
7]

23.sample_di
ct(
'n'
:
3,'
e'
:7,
'
o':
9)
sor
ted(sampl
e_dict
)

a.[
3,7,9]
b.{
'n'
:3,'
e'
:7,
'
o':
9
c.{
'e'
:7.'
n'
:3,
'
o':
9}
d.[
e,n,o]

24.
sel
ectt
heappl
i
cabl
etowi
thst
atement(
checkbox)

a.withstat
ementisusedt oloopoveragenerat
or
b.withstatementencapsul
atestr
y,except
,fi
nal
lypatt
ernf
orcodereuse
c.withstat
ementisusedt oali
asanobject
d.ifanexcepti
onoccursintheblock__exi
t__
()methodoft
hecontextmanageri
scal
l
edt
ocl
eanup
resources

25.
sel
ectt
hecor
rectopt
iont
hatcl
osesf
il
eifexcept
ionoccur
s

a.noneoft heli
stedopt i
ons
b.withopen("demo.txt"
, encodi
ng='ut
f-
8')
asf#per
for
mfi
l
eoper
ati
ons
c.f=open("
demo. txt
",
'f
',
encoding='
utf-
8')f
.r
ead(
)
d.try#codethatcanr aiseerrorpass

26.i
dent
if
ytheout
put

defdemo(
):
t
ry:
ret
urn1
f
inal
ly:
ret
urn3
test=demo( )
print(
test
)

a.er
rormor
ethanoner
etur
nst
atement
b.3
c.1

27.i
dent
if
ytheoupt
ut

fi
l
e=None
f
ori i
nrange(
5):
withopen("
hel
l
o.t
xt"
,"
w")asf
il
e
ifi
>2:
br
eak
pri
ntt
heclosed

a.t
rue
b.f
alse

28.
mat
cht
hest
atementwi
thcor
rectopt
ion

1.
typeerr
or
2.
valueer
ror
3.
runti
meerror

a.r
aisedwhenthebui
lt-
inf uncti
onforadataty pehasthevali
dtypeofargument
s,butt
heargument
s
haveinval
i
dval
uesspecified.
b.r
aisedwhenanoperationorf uncti
onisatt
empt edthati
sinvali
dfort
hespecif
ieddat
aty
pe.
c.r
aisedwhenagenerateder rordoesnotfai
lintoanycategory

sel
ectone:

a.al
l ofthel
ist
edopt
ions
b.1-
c2- a3-b
c.
1-a2- b3-c
d.1-b2-a3-c

29.
whi
cnoper
atort
oimpor
tmodul
esf
rom packages

a..
operat
or
b.oper
ator

30.st
atet
hebel
owst
atement
sar
etr
ueornot

pyt
honmodul
eshoul
dcont
ainonl
ydef
ini
ti
onsl
i
kef
unct
ions,
classesandv
ari
abl
esandnotst
atement
s
l
ikepr
int

a.t
rue b.f
alse

31.
whati
stheout
putoft
hef
oll
owi
ng

defnameFruit
s(*fr
uit
):
pri
nt("
ilove",
fr
uit
)
nameFrui
ts('
Apple'
,'
Mango',
'
orange'
)

sel
ectoneopt
ion
a.('
Il
ove'
,
('Apple'
,
'Mango'
,'
orange'
))
b.Synt
axerrornameFrui
ts()cantakeonlyonear
gument
c.il
oveAppleiloveMangoi loveOrange
d.il
oveApple

32.sel
ectt
hecor
rectst
atement(
checkbox)

a.aref
erencevari
abl
eisanobj ect
b.anobjectmaycontai
not herobject
s
c.anobjectcancont
ainreferencetootherobj
ect
s
d.aref
erencevari
abl
er ef
erst oanobject.

33.
out
putf
ort
hebel
owcode

cl
assHello:
def__init
__(sel
f,name)
:
self.
name=name
defsay Hell
o(self)
:
print
(self.
name)
p1=Hel
lo("Tom")
p2=Hel
lo("Sam")
p2.
sayHello()

a.Hel
loTom
b.Sam
c.Tom
d.Hel
loSam

34.i
dent
if
ytheout
put

cl
assMapPoi nt:
def__ini
t__(
self
,x=0,
y=0)
:
self
.x=x+2
self
.y=y+3
s1=MapPoi nt()
pri
nt(s1.
x,s1.
y )
sel
ectone

a.err
or
b.2,3
c.x,
y
d.,
0

35.sel
ectt
hecor
rectst
atement

chooseoneort
wo

a.tupl
eisimmut abl
eandl i
sti
smut abl
e
b.seti
sanunor deredcoll
ecti
onofuniqueit
ems
c.Dict
inoar
yisanor der
edcollect
ionofkey
-val
uepai
rs
d.tupl
eismutableandlisti
simmut abl
e
36.
chooset
hecor
rectopt
ionst
opr
intpi
const
antasdecl
aredi
nmat
hmodul
e

a.fr
om mathimpor
tpi
print
(math.
pi)
b.fr
om mathimpor
tpipr
int
(pi
)
c.pri
nt(
mathpi)
d.pri
nt(
pi)

37.whatdoest
he"
cycl
e"f
unct
ionf
rom "
it
erat
ors"modul
edo?

a.ret
urnsaniteratorwhichcycl
esthroughthegi
venl
i
stov
erandov
eragai
n
b.ret
urnsaiteratorfort
hegivenit
erableobj
ect
c.conver
tsthegi venli
stint
ogenerator
d.cycl
esthr
ought hegivenli
st

38.whatwoul
dbet
hef
unct
ionr
etur
nifnor
etur
nst
atementi
susedi
nsi
dei
t

a.noneobject
b.anarbit
rar
yobj
ect
c.Err
orfuncti
onmusthav
ear
etur
nst
atement
.

39.whathappensi
fanon-
exi
stentf
il
eisopened?

a.newfil
egetscreat
ed
b.opensanalt
ernati
vefi
le
c.noneoftheli
stedopt
ions
d.rai
sesanexcepti
on

40.sel
ectt
hecor
rectopt
ion

a.cust
om excepti
onisunavai
l
abl
einpython
b.auser-
defi
nedexcepti
oncanbecreatedbyderi
vi
ngaclassfr
om except
ioncl
ass
c.noneoftheli
stedopt
ions
d.auser-
defi
nedexcepti
oncanbederiv
ingaclassfr
om er
rorcl
ass

41.sel
ectt
hatal
lappl
i
cabl
etogener
ator
s(checkbox)

a.generat
orhel
pprogram t
oper for
mf ast
ersincet
hecodedonotwaitf
ort
hewhi
l
edat
asett
obe
generat
ed.
b.generat
ori
susedonl yt
oloopov erl
ist
c.gener
atori
smemor yeffi
cient
d.generat
oryi
eldst
atementr et
urnsonevalueatti
metothecal
l
ingl
oop.

42.i
dent
if
ytheout
put

cubes={
1:1,
2:8,
3:27,
4:64,
5:125}
pri
nt(
cubes.
pop(4))
pri
nt(
cubes)

a.125{ 1:1,2:8,3:
27, 5:
125}
b.4{1:1,2:8,3:27,5:125}
c.64{1:1,2:8,3:27,5:125}
d.noneoft hel i
stedoptions
43.sel
ectt
hecor
rectst
atement

a.__ini
__(
)iscall
edwhenanewobj ecti
sinit
iated
b.singl
eobjectcanbemadef r
om thegivenclass
c.thewayoper ator
sbehavei
npythoncanbechanged.
d.sameoper atormaybehavedi
ff
erentl
ydependinguponoper
ands.

44.whi
chi
sthedef
aul
tval
ueofaf
unct
ionwi
thoutar
etur
nst
atement
?

a.nul
l
b.1
c.none

45.sel
ectt
hecor
rectout
putf
ort
hecodesni
ppet

x=[
5,3,6]
a=i
ter(x)
b=i
ter(x)
pri
nt(next
(a)
)
pri
nt(next
(b)
)

a.
55
b.
12
c.
22
d.
53

46.I
dent
if
ytheout
put

i
=sum=0
whil
ei<=5:
sum+=i
i
=i+1
pr
int
(sum)

a.
1
b.
5
c.
15
c.
4

47.i
dent
if
ytheout
put

tr
y :
fi
le=open("demoFile"
,"
w")
fi
le.wri
te("
Thisfi
l
ef orexcept
ionhandl
ing"
)
exceptIOEr r
or:
print(
"Err
orcan’
tfindfil
eorreaddata"
)
el
se:
print(
"Writ
tencontentinthefi
le"
)
fi
le.
close()

a.Thefileforexcepti
onhandl
i
ng
b.Er
ror
: Cantfindfi
leorr
eaddata
c.Writ
tencont enti
nthefi
le
d.Fi
l
eunav
ail
abl
e

48.
tr
y:
pass
except(
TypeErr
or,
ZeroDi
vi
sionEr
ror
):
pri
nt(
“err
or”
)

a.Ifnoexcepti
onoccurs,pri
nter
ror
b.Alwayspri
nterr
or
c.IfTypeEr
rororZeroDi
vi
sionErr
oroccurs,
pri
ntsErr
or
d.I
fanyExcepti
on( ot
herthanTypeEr
ror,
ZeroDiv
isi
onEr
roroccur
s,pr
int
sEr
ror

49.whatwi
l
lresul
tift
hef
il
eisopenedi
n‘a’
mode?

a.opensafi
lef
orappendingatt
heendoft
hef
il
e.
b.fi
lei
sdel
eted
c.fi
l
eisopenedforr
eadingonl
y
d.fi
lei
sopenedforwri
ti
ng

50.sel
ectt
hecor
rectst
atement

a.el
ementsofsetcanbechanged
b.el
ementsofasetar euni
que
c.asetisanunorderedcol
l
ect
ionofi
tems
d.al
ltheli
stedopti
ons

51.i
deni
fyheouput

cl
asshel l
o()
:
def__repr__(
self
):
retur
n“ _
_repr__
bui
l-
inf
unct
ioncal
l
ed”
def__str__
(self
):
retur
n“ _
_str_
_buil
t-
inf
unct
ioncal
l
ed”
say=hell
o()
pri
nt(say)

a.__str
__bui
lt
-i
nfunctioncal
led
b._
_repr__bui
lt
-i
nf uncti
oncall
ed
c.Error
d.Noneoft heli
stedoptions

55.Thecl
assmet
hodsi
npy
thon

a.unbounded
b.stat
ic
c.bounded
d.non-st
ati
c

56.I
dent
if
ytheout
putoft
hegi
vencode
St
r='
Hel
lo'
St
r.
cent
er(
1,'
1'
)

a.Noneoftheli
stedopt
ions
b.B.Hel
l
o1111
c.1Hell
o1111
d.11Hel
lo11

57.
Sel
ectt
her
esul
t.

cl
assTestClass:
pass
Test
_obj
ect=TestCl
ass(
)
Test
_obj
ect.
at t
ri
but
e=”v
alue”

a.l
ast_
objectwil
lnotbecreatedduetoNameEr r
or:
name‘NoObject’
isdef
ined
b.Cl
asswi l
lnotbecreat
eddueoSy nt
axEr
ror
:Inval
i
dsy nt
ax”except
ion
c.At
tri
buteErr
or:
TestCl
assinstancehasnoat
tri
bute‘a1’
d.Noerror

58.
sel
ectt
hecor
rectst
atement
s

a.sameoper atormaybehavedi
ff
erentl
ydependinguponoper
ands
b._
_ i
nit
__(
)iscall
edwhenaobjectisi
nstant
iated
c.singl
eobjectcanbemadef r
om dif
fer
entclass
d.thewayoper ator
sbehavei
npythoncanbechanged.

59.pyt
honall
owsfunct
ionst
obecal
l
edusi
ngkey
wor
dar
gument
sandkey
wor
dar
gument
smustf
oll
ow
posi
ti
onalar
guments

a.t
rue
b.f
alse

60.
sel
ectt
heout
putoft
hef
oll
owi
ngcodesni
ppet

classUserEr
ror(ValueError
):
pass
classUserEr
ror1(User Er
ror
):
pass
classUserEr
ror2(User Er
ror
1):
pass
forerri
n[UserError,
UserError
1,User
Err
or2]
:
try
:
rai
seerr
exceptUserError:
pri
nt(
"UserError")
exceptUserError1:
pri
nt(
"UserError1")
exceptUserError2:
pri
nt(
"UserError2")

a.val
ueErr
prValueErr
orVal
ueEror
b.UserEr
rorUserEr
rorUser
Err
or
c.User
Err
or2UserErr
or1UserErr
or
d.User
Err
orUserErr
or1UserErr
or2

61.
whatki
ndofer
rordoy
ougetwhi
l
ecompi
l
ingt
hef
oll
owi
ngcode?

pr
int
(st
r/2)

a.Zeroer
ror
b.typeer
ror
c.tr
acebackerr
or
d.noneerror

62.i
dent
if
ytheout
puti
fent
eredcompanyi
scogni
zant
.

i
mpor tsy s
pri
nt("
Entery ourcurr
entcompany:
")
name=" "
whil
eTr ue:
d=sys.stdi
n.read(
1)
i
fd==" \n":
break
name=name+d
pri
nt("
Yourcomapanyi s",
name)

a.Allt
hel i
stedopti
ons
b.cognizant
c.yourcompanyi scogni
zant

63.os.
li
stdi
r(
)isusedf
or

a.cr
eati
nganewdi rectory
b.pr
int
scurrentdirectory
c.cl
onescurrentdirector
y
d.pr
int
salldirect
oriesandf i
l
esi
nsi
dehegi
vendi
rect
ory

64.i
dent
if
ytheouput

ex__t
upl
e=('
Python'
,
)*(
a._
_len_
_()
-a[
::
-1]
[]
)
pri
nt(
ex_
tuple)

a.(‘
Python’
)
b.(
‘Pyhon’
,’
Pyt
hon’
)
c.Err
or
d.0

65.
Ident
if
ytheout
put

fr
uit
_li
st1=['
Apple',
'Berr
y'
,'
Cher
ry'
,'
Papay
a']
fr
uit
_li
st2=fr
uit_l
ist
1
fr
uit
_li
st3=fr
uit_l
ist
1[:]
fr
uit
_li
st2[
0]='Guava'
fr
uit
_li
st3[
1]='Ki
wi '
sum =0
forlsi
n( fr
uit
_li
st1,f
rui
t_l
i
st2,
frui
t_l
i
st3)
:
ifl
s[0]=='Guava'
:
sum +=1
ifl
s[1]=='Ki
wi':
sum +=20
pri
nt(sum)

a.21
b.22
c.2

66.
whi
chcommandi
susedt
oremov
east
ri
ng“
Wor
ld”f
rom l
i
st_
1

a.l
ist
_1.
remove(
“Wor l
d”)
b.l
ist
_1.
removeAll
(“
Wor l
d”)
c.l
i
st_1.
remov
eOne( “
Wor l
d”)
d.l
ist
_1.
remove(Worl
d)

67.i
dent
if
ytheout
put

vowels=[‘
a’
,’e’,

i’
,’
o’
,’
u’
]
pri
nt(
v owels,3)

a.[’o’
,’
u’
]
b.[‘
a’,

e’,
’i

,’
o’,
’u’]
c.[‘
a’,

e’]
d.[’i
’,

o’]
['
a'
,'e'
,'
i'
,'
o',
'u']3

68.sel
ectt
hecor
rectopt
ions

a.Al
lofli
stedopt i
ons
b.__
new_ _(
)met hodautomat i
call
yinv
okest he__
ini
t__met
hod
c.__
ini
t__met hodisdefinedintheobjectcl
ass
d.__
eq(other)methodisdefinedintheobjectcl
ass.

69.Whathappenswhen‘
1’==1i
sexecut
edi
nPy
thon?
Sel
ectone:

a.wegetaTr ue
b.wegetaFal se
c.Val
ueErr
oroccurs
d.anTypeErr
oroccurs

70.St
atewhet
herthebelowstatementi
sTrueorFal
se:
Pri
vat
emember sofaclasscannotbeaccessed.

Sel
ectone:

True
False
71.I
nPy
thon,
whati
stheout
putoft
hef
oll
owi
ng?

pr
int
("
Hel
l
o{0!
r}and{
0!s}
".
for
mat
('
foo'
,'
bi
n'
))

Sel
ectone:

a.Hel
lofooandfoo
b.Hel
lofooand‘bi
n’
c.Er
ror
d.Hel
lo‘
foo’andfoo

72.Aclassi
nwhichoneormor
emet
hodsar
eonl
yimpl
ement
edt
orai
seanexcept
ioni
scal
l
edan
abst
ractcl
ass.

Sel
ectone:

True
False

73.Whatwi
llbet
heout
putoft
hef
oll
owi
ngPy
thonst
atement
?
>>>"
a"+"
bc"

Sel
ectone:

abc
ab
bca
a

74.Whati
sthemaxi
mum char
act
ersal
i
necancont
aini
nPy
thon?

Sel
ectone:

82
89
79
72

75.Whati
sthemaxi
mum possi
blel
engt
hofani
dent
if
ieri
nPy
thon?

Sel
ectone:

a.32characters
b.31characters
c.127characters
d.64characters

76.Whi
choneoft
hef
oll
owi
ngi
snotapy
thon'
spr
edef
ineddat
aty
pe?
Sel
ectone:

a.Cl
ass
b.Tuple
c.Li
st
d.Dict
ionar
y

77.Whenwi
l
ltheel
separ
toft
ry-
except
-el
sebeexecut
edi
nPy
thon?

Sel
ectone:

a.whenanexcept
ionoccur
sint
oexceptbl
ock
b.whennoexcept
ionoccur
s
c.Al
ways
d.whenanexcept
ionoccur
s

78.Whi
choft
hef
oll
owi
ngi
sthemostsui
tabl
edef
ini
ti
onf
orencapsul
ati
on?

Sel
ectone:

Meansofbundl
ingi nst
ancevar
iabl
esandmet hodsinordertorest
ri
ctaccesstocert
aincl
assmember
s
Abil
it
yofacl
asst oderivemembersofanothercl
assasapar tofit
sowndef i
nit
ion
All
owsfori
mplement ati
onofel
egantsoftwar
ethatiswelldesi
gnedandeasilymodif
ied
Focusesonvar
iablesandpassi
ngofv ar
iabl
estofunct
ions

79.Whati
sset
att
r()usedf
ori
nPy
thon?

Sel
ectone:

a.Tocheckifanattr
ibut
eexi
stsornot
b.Todelet
eanat t
ri
bute
c.Toaccesstheattr
ibut
eoft
heobject
d.Tosetanattr
ibute

80.Whi
choft
hesei
snotaf
undament
alf
eat
ureofobj
ect
-or
ient
edpr
ogr
ammi
ng?

Sel
ectone:

I
nherit
ance
I
nstanti
ation
Polymorphism
Encapsulati
on

You might also like