Q.No.
Question
1. Whichofthefollowingisa valididentifier:
i. 9type ii. _type iii. Same-type iv.True
2. Whichofthe followingisarelationaloperator:
i. > ii. // iii.or iv.**
3. Whichofthefollowingisalogicaloperator:
i. + ii. /= iii.and iv.in
4. Identifythemembership operatorfromthefollowing:
i. in ii. notin iii.bothi&ii iv.Onlyi
5. Whichoneisaarithmeticoperator:
i. not ii. ** iii.bothi&ii iv.Only ii
6. Whatwill bethecorrectoutputofthestatement:>>>4//3.0
i. 1 ii. 1.0 iii1.3333 iv.None oftheabove
7. Whatwillbethecorrectoutputofthe statement: >>> 4+2**2*10
i. 18 ii. 80 iii.44 iv. None ofthe above
8. Givetheoutputofthefollowingcode:
>>>a,b=4,2
>>>a+b**2*10
i. 44 ii. 48 iii.40 iv. 88
9. Givetheoutputofthefollowingcode:
>>> a,b=4,2.5
>>>a-b//2**2
i. 4.0 ii. 4 iii.0 iv. None oftheabove
10. Givetheoutputofthefollowingcode:
>>>a,b,c=1,2,3
>>>a//b**c+a-c*a
i. -2 ii.-2.0 iii.2.0 iv. None ofthe above
11. Ifa=1,b=2 andc= 3thenwhichstatementwillgive theoutputas :2.0fromthefollowing:
i. >>>a%b%c+1 ii.>>>a%b%c+1.0 iii.>>>a%b%c iv.a%b%c-1
12. Whichstatementwillgivetheoutputas:Truefromthefollowing :
i. >>>not -5 ii.>>>not5 iii.>>>not0 iv.>>>not(5-1)
13. Givetheoutputofthefollowingcode:
>>>7*(8/(5//2))
i. 28 ii.28.0 iii.20 iv.60
14. Givetheoutputofthefollowingcode:
>>>importmath
>>>math.ceil(1.03)+math.floor(1.03)
i. 3 ii.-3.0 iii.3.0 iv. None ofthe above
15. Whatwillbetheoutputofthefollowingcode:
>>>importmath
>>>math.fabs(-5.03)
i. 5.0 ii.5.03 iii. -5.03 iv.Noneoftheabove
Singlelinecomments inpythonbeginwith................................symbol.
16. i. # ii. “ iii. % iv. _
17. Whichofthefollowing arethefundamentalbuilding blockofa pythonprogram.
i. Identifier ii. Constant iii. Punctuators iv.Tokens
18. Theinput()functionalwaysreturnsavalueof..............................type.
i. Integer ii. float iii. string iv. Complex
19. …...........functionisusedtodeterminethedatatypeofavariable.
i. type() ii. id() iii.print( ) iv.str()
20. Thesmallestindividualunitinaprogramisknownasa……………
i. Token ii. keyword iii.punctuatoriv.identifier
21. Whichofthefollowingisnotadecisionmakingstatement
i. if..elsestatementii.for statement iii.if-elifstatement iv. ifstatement
22. …………loopisthebestchoicewhenthenumberofiterationsareknown.
i. while ii. do-while iii. for iv.Noneofthese
23. Howmanytimeswillthefollowingcode beexecuted.
a=5
whilea>0: print(a)
print(“Bye”)
i. 5timesii.Once iii.Infinite iv. None ofthese
24. Whatabandonsthecurrentiterationoftheloop
i. continueii.stopiii. infinite iv.Break
25. Find theoutputofthe following python program
foriinrange(1,15,4): print(i, end=’,’)
i. 1,20,3ii.2,3,4 iii.1,5,10,14 iv.1,5,9,13
26. …………loopisthebestwhenthenumberofiterationsare not known.
i. while ii. do-while iii. for iv.Noneofthese
27. Inthe nestedloop loopmustbeterminatedbeforetheouter loop.
i. Outer ii. enclosing iii.inner iv. Noneofthese
28. … statementisanemptystatementinpython.
i. pass ii.break iii.continue iv. if
29. Howmanytimeswillthefollowingcode beexecuted
foriinrange(1,15,5): print(i,end=’,’)
i. 3 ii.4 iii.1 iv.infinite
30. Symbolusedto endtheifstatement:
i. Semicolon(;)ii.Hyphen(-)iii.Underscore( _)iv.colon(:)
31. Whichofthefollowingisnotapythonlegalstringoperation.
i. ‘abc’+’aba’ii.‘abc’*3 iii.‘abc’+3 iv.‘abc’.lower()
32. Whichofthefollowingisnotavalidstringoperation.
i. Slicing ii.concatenation iii.Repetition iv.floor
33. Whichofthefollowingisamutabletype.
i. string ii. tuple iii.int iv.list
34. Whatwillbetheoutputofthefollowingcode str1=”I
love Python”
strlen=len(str1)+5
print(strlen)
i. 18 ii. 19 iii. 13 iv. 15
35. Whichmethodremovesalltheleadingwhitespacesfromtheleftofthe string.
i. split() ii. remove() iii.lstrip() ivrstrip()
36. ItreturnsTrueifthestringcontainsonlywhitespacecharacters,otherwisereturns
i) isspace() ii. strip() iii. islower() iv. isupper()
37. Itconvertsuppercaselettertolowercaseandviceversaofthegivenstring.
i. lstrip() ii. swapcase() iii. istitle() iv.count()
38. Whatwillbetheoutputofthe followingcode.
Str=’Hello World! Hello Hello’
Str.count(‘Hello’,12,25)
i. 2 ii. 3 iii. 4 iv. 5
39. Whatwillbetheoutputofthe followingcode.
Str=”123456”
print(Str.isdigit())
ii. True ii. False iii. None iv. Error
40. Whatwillbetheoutputofthe followingcode.
Str=”python 38”
print(Str.isalnum())
iii. True ii. False iii. None iv. Error
41. Whatwillbetheoutputofthe followingcode.
Str=”pyThOn”
print(Str.swapcase())
i. PYtHoN ii. pyThon iii. python iv. PYTHON
42. Whatwillbetheoutputofthe followingcode.
Str=”Computers”
print(Str.rstrip(“rs”))
i. Computer ii. Computers iii. Compute iv. compute
43. Whatwillbetheoutputofthe followingcode.
Str=”This is Meera\’ pen”
print(Str.isdigit())
i. 21 ii. 20 iii. 18 iv. 19
44. Howmanytimesistheword‘Python’printedinthefollowingstatement. s = ”I
love Python”
for ch in s[3:8]:
print(‘Python’)
i. 11times ii. 8times iii. 3times iv. 5times
45. Whichofthefollowingisthecorrectsyntaxofstringslicing:
i. str_name[start:end] iii.str_name[start:step]
ii. str_name[step:end] iv.str_name[step:start]
46. Whatwillbetheoutputofthe followingcode? A=”Virtual
Reality” print(A.replace(‘Virtual’,’Augmented’))
i. VirtualAugmented iii.RealityAugmented
ii. AugmentedVirtual iv.AugmentedReality
47. Whatwillbetheoutputofthe followingcode? print(“ComputerScience”.split(“er”,2))
i. [“Computer”,”Science”] iii.[“Comput”,”Science”]
ii. [“Comput”,”erScience”] iv.[“Comput”,”er”,”Science”]
48. Followingsetofcommandsareexecutedinshell,whatwillbetheoutput?
>>>str="hello"
>>>str[:2]
i.he ii. lo iii.olleh iv.hello
49. …..........functionwillalwaysreturntupleof3elements.
i. index() ii. split() iii. partition() iv.strip()
50. Whatisthecorrectpythoncodetodisplaythelastfourcharactersof“DigitalIndia”
i. str[-4:] ii.str[4:] iii. str[*str] iv.str[/4:]
51. GiventhelistL=[11,22,33,44,55],writetheoutput ofprint(L[::-1]).
i.[1,2,3,4,5]ii.[22,33,44,55]iii.[55,44,33,22,11]iv.Errorin code
52. Whichofthefollowing canadd anelementat anyindexinthelist?
i.insert() ii.append() iii.extend() iv.allofthese
53 Whichofthefollowingfunctionwillreturnalistcontainingallthewordsofthegivenstring? i .
split() ii.index() i i i . count() iv.list()
54. Whichofthe followingstatementsareTrue.
a. [1,2,3,4]>[4,5,6]
b. [1,2,3,4]<[1,5,2,3]
c. [1,2,3,4]>[1,2,0,3]
d. [1,2,3,4]<[1,2,3,2]
i. a,b,d ii.a,c,d iii.a,b,c iv.Onlyd
55. If l1=[20,30] l2=[20,30] l3=[‘20’,’30’] l4=[20.0,30.0]thenwhichofthe following
statements will not return ‘False’:
a. >>>l1==l2 b.>>>l4>l1 c.>>>l1>l2 d. >>>l2==l2
i. b,c ii.a,b,c iii.a,c,d iv.a,d
56. >>>l1=[10,20,30,40,50]
>>>l2=l1[1:4]
Whatwillbetheelementsoflistl2:
i. [10,30,50] ii.[20,30,40,50] iii.[10,20,30]iv.[20,30,40]
57. >>>l=[‘red’,’blue’]
>>>l=l+‘yellow’
Whatwillbetheelementsoflistl:
i.[‘red’,’blue’,’yellow’]ii.[‘red’,’yellow’]iii.[‘red’,’blue’,’yellow’] iv.Error
58. Whatwillbetheoutputofthefollowingcode:
>>>l=[1,2,3,4]
>>>m=[5,6,7,8]
>>>n=m+l
>>>print(n)
i. [1,2,3,5,6,7,8]ii. [1,2,3,4,5,6,7,8]iii. [1,2,3,4][5,6,7,8]iv. Error
59. Whatwillbetheoutputofthefollowingcode:
>>>l=[1,2,3,4]
>>>m=l*2
>>>n=m*2
>>>print(n)
i[1,2,3,4,1,2,3,4,1,2,3,4] ii.[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4] iii.[1,2,3,4][4,5,6,7
iv.[1,2,3,4]
60. Matchthecolumns:if
>>>l=list(‘computer’)
ColumnA ColumnB
1. L[1:4] a.[‘t’,’e’,’r’]
2. L[3:] b.[‘o’,’m’,’p’]
3. L[-3:] c.[‘c’,’o’,’m’,’p’,’u’,’t’]
4. L[:-2] d.[‘p’,’u’,’t’,’e’,’r’]
i. 1-b,2-d,3-a,4-c iii.1-c,2-b,3-a,4-d
ii. 1-b,2-d,3-c,4-a iv.1-d,2-a,3-c,4-b
61. Ifalistiscreatedas
>>>l=[1,2,3,’a’,[‘apple’,’green’],5,6,7,[‘red’,’orange’]] thenwhat willbetheoutputofthe
followingstatements:
>>>l[4][1]
i. ‘apple’ iii.‘green’
ii. ‘red’ iv.‘orange’
62. >>>l[8][0][2]
i. ‘d’ iii.‘e’
ii. ‘r’ iv.‘o’
63. >>>l[-1]
i. [‘apple’,’green’] iii.[‘red’,’orange’]
ii. [‘red’] iv. [’orange’]
6 >>>len(l)
4 i. 10 iii. 9
ii. 8 iv 11
65. Whatwillbetheoutputofthefollowingcode:
>>>l1=[1,2,3]
>>>l1.append([5,6])
>>>l1
i. [1,2,3,5,6] ii.[1,2,3,[5,6]]iii.[[5,6]]iv.[1,2,3,[5,6]]
66. Whatwillbetheoutputofthefollowingcode:
>>>l1=[1,2,3]
>>>l2=[5,6]
>>>l1.extend(l2)
>>>l1
ii. [5,6,1,2,3] ii.[1,2,3,5,6]iii.[1,3,5]iv.[1,2,3,6]
67. Whatwillbetheoutputofthefollowingcode:
>>>l1=[1,2,3]
>>>l1.insert(2,25)
>>>l1
iii. [1,2,3,25] ii.[1,25,2,3]iii.[1,2,25,3]iv.[25,1,2,3,6]
68. >>>l1=[10,20,30,40,50,60,10,20,10]
>>>l1.count(‘10’)
i. 3 ii.0 iii. 2 iv. 9
69. Whichoperatorscanbeused withlist?
i. in ii.notin iii.both(i)&(ii) iv.Arithmeticoperatoronly
70. Whichofthefollowingfunctionwillreturnthefirstoccurrenceofthespecifiedelementinalist.
i. sort() ii. value() iii. index() iv.sorted()
71. Whichofthestatement(s)is/are correct.
i. Pythondictionaryisanordered collectionofitems.
ii. Pythondictionaryis amapping ofuniquekeystovalues
iii. Dictionaryismutable.
iv. Allofthese.
72. ………functionisusedtoconvertasequencedatatypeinto tuple.
i. List() iituple() iiiTUPLE iv.tup()
73. Ittup=(20,30,40,50), whichofthefollowingisincorrect
i. print(tup[3])ii.tup[2]=55iii.print(max(tup)) iv.print(len(tup))
74. Considertwotuplesgivenbelow:
>>>tup1=(1,2,4,3)
>>>tup2=(1,2,3,4)
Whatwillthefollowingstatementprint(tup1<tup2)
i. True ii.False iii. Error iv.None ofthese
75. Whichfunctionreturnsthenumberofelementsinthe tuple
i. len() ii.max() iii. min() iv.count()
76. Whichfunction isusedtoreturnavalueforthegivenkey.
i. len() ii.get() iii.keys() iv.None ofthese
77. Keysofthe dictionarymustbe
i. similarii. unique iii.canbesimilarorunique iv.Allofthese
78. Whichofthefollowingiscorrecttoinsertasingleelementinatuple.
i. T=4 ii.T=(4) iii.T(4,) iv.T=[4,]
79. Whichofthefollowingwilldeletekey-valuepairforkey=’red’formadictionaryD1
i. DeleteD1(“red”) ii.del.D1(“red”)iii.delD1[“red”]iv.delD1
80. Whichfunctionisusedtoremoveallitemsformaparticulardictionary.
i. clear() ii.pop()iii.delete iv.rem( )
81. Indictionarytheelementsareaccessedthrough
i. key ii.valueiii. index iv.None ofthese
82. Whichfunctionwillreturnkey-value pairs ofthe dictionary
i. key() ii.values( ) iii.items() iv.get()
83 Elementsinatuplecanbe of type.
i. Dissimilarii.Similar iii.bothi& iiiv.Noneofthese
84 Tocreateadictionary,key-valuepairsareseparatedby…………….
i. (;) ii.(,) iii.(:) iv.(/)
85 Whichofthefollowingstatementsarenotcorrect:
a. Anelementinadictionaryisacombinationofkey-value pair
b. Atupleisamutabledatatype
c. Wecanrepeatakeyindictionary
d. clear( )functionisusedtodeletedthedictionary.
i. a,b,c ii. b,c,d iii.b,c,a iv.a,b,c,d
86 Whichofthefollowingstatements arecorrect:
a. Listscanbeusedaskeysinadictionary
b. Atuplecannot storelistasanelement
c. Wecanuseextend()functionwithtuple.
d. Wecannot deleteadictionaryoncecreated.
i. a,b,c ii. b,c,d iii.b,c,a iv.None ofthese
87 Likelists,dictionariesare whichmeantheycanbechanged.
i. Mutable ii.immutable iii. variable iv. Noneofthese
88 Tocreateanemptydictionary,weuse
i. d=[] ii.d =() iii.d= {} iv.d=<>
89 Tocreatedictionarywithnoitems,weuse
ii. Dict ii.dict()iii.d=[ ] iv.None ofthese
90 Whatwillbethe output
>>>d1={‘rohit’:56,”Raina”:99}
>>>print(“Raina”ind1)
i. True ii. False iii. Nooutput iv.Error
91 Rahulhascreatedtheatuplecontainingsome numbersas
>>>t=(10,20,30,40)
nowhewantstodothefollowingthingshelp him
1. Hewanttoaddanewelement 60inthetuple, whichstatement heshoulduseoutofthe given four.
i. >>>t+(60)
ii. >>>t+ 60
iii. >>>t+(60,)
iv. >>>t+(‘60’)
92 Rahulwantstodeletealltheelementsfromthetuple,whichstatementheshould use
i. >>>delt
ii. >>>t.clear()
iii. >>>t.remove()
iv. >>>None ofthese
93 Rahulwantsto displaythelastelementofthetuple,whichstatementheshoulduse
i. >>>t.display()
ii. >>>t.pop()
iii. >>>t[-1]
iv. >>>t.last()
94 Rahulwantsto addanewtuplet1to thetuplet,whichstatementheshoulduse
i. >>>t+t1
ii. >>>t.add(t1)
iii. >>>t*t1
iv. Noneof these
95 Rahulhas issuedastatement afterthatthetuplet is replacewithemptytuple, identifythestatement he had
issued out of the following:
i. >>>delt
ii. >>>t=tuple()
iii. >>>t=Tuple()
iv. >>>deletet
96 Rahulwantsto countthathowmanytimesthenumber 10has come:
i. >>>t.count(10)
ii. >>>t[10]
iii. >>>count.t(10)
iv. Noneof these
97 Rahulwantto knowthat howmanyelementsarethere inthetuplet,whichstatement heshoulduse out of
the given four
i. >>>t.count()
ii. >>>len(t)
iii. >>>count(t)
iv. >>>t.sum()
98 >>>t=(1,2,3,4)
Writethestatementshouldbeusedtoprintthefirstthreeelements3times
i. >>>print(t*3)
ii. >>>t*3
iii. >>>t[:3]*3
iv. >>>t+t
99 Matchtheoutputwiththe statementgivenincolumnAwithColumnB
1. >>>tuple([10,20,30]) a.>>>(10,20,30)
2. >>>(“Tea”,)*3 b.>>>2
3. >>>tuple(“Item”) c.>>>('Tea', 'Tea', 'Tea')
4. >>>print(len(tuple([1,2]))) d.>>>('I','t', 'e','m')
i. 1-b,2-c,3-d,4-a
ii. 1-a,2-c,3-d,4-b
iii. 1-c,2-d,3-a,4-a
iv. 1-d,2-a,3-b,4-c
100 Writetheoutputofthefollowingcode:
>>>d={‘name’:’rohan’,’dob’:’2002-03-11’,’Marks’:’98’}
>>>d1={‘name’:‘raj’)
>>>d1=d.copy()
>>>print(“d1:”d1)
i. d1:{'name':'rohan','dob':'2002-03-11','Marks':'98'}
ii. d1={'name':'rohan','dob':'2002-03-11','Marks':'98'}
iii. {'name':'rohan','dob':'2002-03-11','Marks':'98'}
iv. (d1:{'name': 'rohan','dob':'2002-03-11','Marks':'98'})