0 ratings0% found this document useful (0 votes) 193 views199 pagesPython MCQs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Python MCQ
1. Which of the following version of Python was released in December, 2015 by
Python.org?
3.3
3.5.1
2.4
2.6
Boge
N
Python files are saved with the extension as ...?
-python
pe
Dy
pi
aoe
3. What is the name of the GUI that comes in-built as an interactive shell with
Python?
a. PGUI
b. Pyshell
c. IDLE
d. PythonSh
-
IDLE stands for ... ?
Indigenous Development Lab
Integrated Development Environment
Tnteorated Navelaners T.acal Fnviranment
SsAKC R EO UC EUpeLo ULE Girne
|. Indie Developers Environment
a
y
The function to display a specified message on the screen is ... ?
print
display
run
output
poo
2
Which of the following is an assignment operator in Python?
Boge
7. Which of the following is used to initialize multiple variables with a common
value?
8. Comments in Python begin with ...?
{
%
*
#
aBoeoe
9. A user-specified value can be assigned to a variable with this function ...b. emer
c. input
d. value
10. User input is read as ...?
a. Floating Decimal
b. Text String
c. Boolean Value
d. Integer
11. Output displayed by the print function will add this invisible character at the
end of the line by default ...
aoge
aage
12. Multiple values specified in parentheses to print function will display each
value separated with this by default...
a. Single Space
b. Double Space
c. Anew Line
d. Double Lines
13. Which of the following will provide an ! character as alternative separator
for the print function?
a. sep is !
b. separate = !
c. sep >>"!
d. sep ="""14, Which of the following will provide a * character as alternative line ending
for the print function?
a. end to *
b. end as *
c. end ="*"
d. ending ="*"
15. For which type of error does the interpreter halts and reports the error but
does not execute the program?
a. Semantic error
b. Syntax error
c, Runtime error
d. All type of errors
16. For which type of error does the interpreter runs the program but halts at
error and reports the error as an "Exception"?
a. Semantic error
b. Syntax error
c, Runtime error
d. All type of errors
17. For which type of error does the interpreter runs the program and does not
report an error?
a. Semantic error
b. Syntax error
c. Runtime error
d. All type of errors
18, What will be the output after the following statements?y 3
print(x / y)
KeNN
pBoeoe
&&
19. What will be the output after the following statements?
x=8
y=2
print(x // y)
a. 4.0
b.4
c. 16
d. 16.0
20. What will be the output after the following statements?
x=5
ys4
print(x % y)
HENS
58
poe
21. What will be the output after the following statements?a3
b.2
a5
d.1
22. What will be the output after the following statements?
5
7
x ts y
print(x)
pose
5
wus
&
23. What will be the output after the following statements?
print(x)
a. 10
b. 25
ce 15
d. -1524. What will be the output after the following statements?
x % y
print(x)
a.
b.
«
d.
WN
8
gs
25. What will be the output after the following statements?
x=3
y=7
print(x == y)
a.y=7andx=3
b. True
c.x=3andy=3
d. False
26. What will be the output after the following statements?
x=8
y=6
print(x != y)
a.y=6andx=8
b. Truec.x=6andy=6
d. False
27. What will be the output after the following statements?
x = 83
y = 57
print(x > y)
a. True
b. False
c. Yes
d. No
28. What will be the output after the following statements?
x= 72
y = 64
print(x < y)
a. True
b. False
c. Yes
d. No
29. What will be the output after the following statements?
x = True
y = False
print(x and y)
a. Trueb. False
c. Not defined
d. xy
30. What will be the output after the following statements?
x = True
y = False
print(x or y)
a. True
b. False
c. Not defined
d.xy
31. What will be the output after the following statements?
x = True
y = False
Print (not x)
a. True
b. False
c. Not defined
dy
32. What will be the output after the following statements?
x = True
False
y
print(not y)a, True
b. False
c. Not defined
d.x
33. What will be the output after the following statements?
x = 20
y = 40
z= y if (y > x) else x
print(z)
a. True
b. False
c. 20
d. 40
34, What will be the output after the following statements?
x = 50
y = 10
z= y if (y > x) else x
print(z)
a. True
b. False
c. 50
d.10
35. What will be the output after the following statements?
x
65
53z= y if (x % 2 == 0) else x
print(z)
a. True
False
65
53
aos
36. What will be the output after the following statements?
x 46
y = 98
z= y if (y % 2 == 0) else x
print(z)
a, True
b. False
c. 46
d. 98
37. What will be the output after the following statements?
xs2*4+7
print(x)
a. 30
b.15
c. 22
d. 247
38. What will be the output after the following statements?x=7* (445)
print (x)
39. What will be the output after the following statements?
x = '24' + "16"
print(x)
a. 40
b. 2416
c. 21
d. 46
40. What will be the output after the following statements?
x= 15 + 35
print(x)
a. 40
b. 153
c. 50
d. 1535
41. What will be the data type of x after the following statement if input entered
is 18?
x = input('enter a number: ')a. Float
b. String
c. List
d. Integer
42. What will be the data type of y after the following statements if input entered
is 50?
input('enter a number: ')
int(x)
Float
String
List
Integer
Boe
43. What will be the data type of y after the following statements?
7
float(x)
Float
String
List
Integer
Boe
44, What will be the data type of y after the following statements?
48
str(x)a. Float
b. String
c. List
d. Integer
45. What will be the output after the following statements?
a. All three will have the value of 3
b. All three will have the value of 100
c, All three will have the value of 300
d. x and y will have arbitrary values, while z will have the value of 300
47. What will be the value of x, y and z after the following statement?
xX ¥, 253, 4, 5
a. All three will have the value of 3
b. All three will have the value of 345c. x will have the value of 3, y will have the value 4 and z will have the value of
5
d. x and y will have arbitrary values, while z will have the value of 345
48. What is the data type of x after the following statement?
x = [7, 8, 9, 10]
a. List
b. Dictionary
c. Tuple
d. String
49. What is the data type of x after the following statement?
x = ['Today', ‘Tomorrow’, 'Yesterday']
a. List
b. Dictionary
c. Tuple
d. String
50. What will be the output after the following statements?
x = ['Today', 'Tomorrow', 'Yesterday']
y = x{1]
print(y)
a.xl
b. Today
c. Tomorrowd. Yesterday
51. What will be the output after the following statements?
x = [25, 35, 45]
= x[0]
print (y)
a. x0
b.25
c. 35
d. 45
52. What will be the output after the following statements?
x = [10, 20, 30]
= x1] + x{2]
print (y)
a. 20
b. 30
c. 40
d.50
53. What will be the output after the following statements?
x = ['Sunday', ‘Monday’, 'Tuesday']
y = x(1] + x[2]
print(y)
a. MondayTuesday
b. SundayMondayc. SunMonday
d. Monday Tuesday
54, What will be the output after the following statements?
x = [[0-0, 1.0, 2.0],[4.0, 5.0, 6.0]]
y = x[1][2]
print(y)
a. 0.0
b. 1.0
c. 5.0
d. 6.0
55. What will be the output after the following statements?
x = [[0.0, 1.0, 2.0],[4.0, 5.0, 6.0]]
y = x[0][1] + x[1][0]
print(y)
a. 1.0
b. 4.0
c.5.0
d. 6.0
56. What will be the output after the following statements?
x=3
y 4
print(x*y)
a3b.4
34
d.12
57. What will be the output after the following statements?
x = [15, 45, 85, 95]
print (x[3]-x[1])
a. 30
b. 40
c. 50
d.10
58. What will be the output after the following statements?
x= [5, 4, 3, 2]
print(x)
59. What will be the output after the following statements?
x= [5, 4, 3, 2]
x.append(1)
print(x)©. 5432
d. (5, 4, 3, 2, 1]
60. What will be the output after the following statements?
x= [5, 4, 3, 2]
x.insert(1, 0)
print (x)
61. What will be the output after the following statements?
x = [5, 4, 3, 2]
x.remove(2)
print(x)
aoe
RESY
RRN
Sunn
62. What will be the output after the following statements?
x = [5, 4,
3, 2, 1)
print(x.pop(3))
oe
woeao
HN
63. What will be the output after the following statements?
x= [5, 4, 3, 2, 1]
print(x,index(1))
pooe
BNwR
64, What will be the output after the following statements?
x = [5, 4, 3, 2, 1]
x-extend(x)
print(x)
65. What will be the output after the following statements?
x = [5, 4, 3, 2, 1]
y = [0, 5, 10]
x.extend(y)
print(x)
a. (5, 4,3, 2, 1,0, 5, 10]-
. [5, 4, 3, 2, 1]
|. [0, 5, 10, 5, 4, 3, 2, 1]
pos
66. What will be the output after the following statements?
x= [5, 4, 3, 2, 1]
y = [10, 5, 0]
x.extend(y)
print(y)
a. [5, 4,3, 2, 1, 10, 5, 0]
b.[]
c. [10, 5, 0, 5, 4, 3, 2, 1]
a. [10, 5, 0]
67. What will be the output after the following statements?
x= [5, 4, 3, 2, 1]
y = [10, 5, 0]
y-extend(x)
print(y)
a. [5, 4,3, 2, 1, 10, 5, 0]
b. [10, 5, 0, 5, 4, 3, 2, 1]
c. (5, 4,3, 2, 1]
d. [10, 5, 0]
68. What will be the output after the following statements?
x = [5, 4, 3, 2, 1]
x.reverse()
print(x)69. What will be the output after the following statements?
x = [25, 14, 53, 62, 11]
x.sort()
print(x)
a. [11, 14, 25, 53, 62]
b. [25, 14, 53, 62, 11]
c. (62, 53, 25, 14, 11]
d. (25, 53, 62, 14, 11]
70. What will be the output after the following statements?
x = ['25', ‘Today’, '53', ‘Sunday’, '15"]
x.sort()
print(x)
a. ‘Today’, ‘Sunday’, '15', '25', '53']
5 ‘Today’, '15', '25', '53']
‘Sunday’, 'Today']
, Today’, 'Sunday’]
d. ['15', "25" '53)
71. What will be the output after the following statements?
= [25, 'Today', 53, 'Sunday', 15]
x.reverse()print(x)
a. ["Today’, ‘Sunday’, 15, 25, 53]
b. [15, 'Sunday’, 53, Today’, 25]
c. [15, 25, 53, 'Sunday’, 'Today']
d. (15, 25, 53, ‘Today’, 'Sunday']
72. What will be the output after the following statements?
x = [25, 35, 53, 25, 52, 35, 25]
print (x.count(25))
pose
wuwh
RSPR
73. What will be the output after the following statements?
x = [25, 35, 53, 25, 52, 35, 25]
print (1en(x))
pooP
wun
a
&
74, What will be the output after the following statements?
x = [25, 35, 53, 25, 52, 35, 25]
Len(x)
print (x)a
a. 2!
b.5
a7
d. [25, 35, 53, 25, 52, 35, 25]
75. What will be the output after the following statements?
x = [25, 35, 53, 25, 52, 35, 25]
del x[3]
print (x)
a. [25, 35, 53, 52, 35, 25]
b. [25, 5, 5, 25, 52, 5, 25]
c. [35, 53, 52, 35]
d. [25, 35, 53, 25, 52, 35, 25]
76. What will be the output after the following statements?
x= [5, 3, 6, 2, 4 8, 1]
del x[2:3]
print(x)
77. What will be the output after the following statements?
x = [5, 3, 6, 2, 4, 0, 7]
del x[0:7]print(x)
a (]
b.[5, 3, 6, 2, 4, 0, 7]
c. 15, 3, 6, 2, 4, 0
d. [3, 6, 2, 4, 0]
78. What will be the output after the following statements?
x= [5, 3, 6, 2, 4, 0, 7]
del x[0:4]
print(x)
a. []
b.[5, 3, 6, 2, 7]
c. 15, 3, 6, 2, 4, 0]
d. [4, 0, 7]
79. What will be the output after the following statements?
x = [5, 3, 6, 2, 4, 0, 7]
del xf:]
print(x)
aogP
ERAS
80. What will be the output after the following statements?
x= [4, 0, 7]y = str(x[0]) + str(x[1])
print(y)
aoge
NBar
81. What will be the output after the following statements?
[4, ®, 7]
y = float(x[0] + x[2])
print(y)
a.1l
b. 11.0
c. 47.0
d. 47
82. What will be the data type of x after the following statement?
x = (34, 81, 50)
a. List
b. String
c. Dictionary
d. Tuple
83. What will be the data type of x after the following statement?
x = 'Python 3 Test’a. List
b. String
c. Dictionary
d. Tuple
84, What will be the data type of x after the following statement?
x = [2290, 376, 198]
a. List
b. String
c. Dictionary
d. Tuple
85. What will be the data type of x after the following statement?
x = {'lang' :'Python', ‘version’ : '3'}
a. List
b. Set
c. Dictionary
d. Tuple
86. What will be the data type of x after the following statement?
x = {2015, 2016, 2017, 2018}
a. List
b. Set
c. Dictionaryd. Tuple
87. What will be the data type of x after the following statement?
x = [2016, 'Leap Year", 'True']
a. List
b. String
c. Dictionary
d. Boolean
88. What will be the data type of x after the following statement?
x = False
a. List
b. String
c. Dictionary
d. Boolean
89. Which of the following function can be used to find the data type of a
variable?
a. data()
b. typeQ)
c. true()
d. str()
90. What will be the output after the following statements?
x = [24, 50, 37]y = 24 in x
print(y)
a. x[0]
b. [24]
c. True
d. False
91. What will be the output after the following statements?
x= ('A', "BY, 1c}
y = 'b' in x
print(y)
a. x{1]
b.['B']
c. True
d, False
92. What will be the output after the following statements?
x = "Python!
y='y' inx
print(y)
a. [1]
by
c. True
d. False
93. What will be the output after the following statements?x = {0:4, 1:8, 2:16, 3:32}
Oinx
y
print(y)
a. x[0]
b. [24]
c. True
d, False
94. What will be the output after the following statements?
x = {0:4, 1:8, 2:16, 3:32}
y=8inx
print(y)
a. x{0]
b. [24]
c. True
d. False
95. What will be the data type of x after the following statements?
false = "This is not true"
x = false
a. List
b. String
c. Dictionary
d. Boolean
96. Which of the following is immutable (values that cannot be changed)?
a. Listb. Dictionary
c. Tuple
d. Set
97. Which of the following has only unique values?
a. List
b. Dictionary
c. Tuple
d. Set
98. What will be the output after the following statements?
x = (0:4, 1:8, 2:16, 3:32}
print(x.keys())
a. dict_keys((0, 1, 2, 3])
b. dict_keys{0, 1, 2, 3}
c. dict_keys(0, 1, 2, 3)
d. dict_keys[0, 1, 2, 3]
99. What will be the output after the following statements?
x = (0:4, 1:8, 2:16, 3:32}
print(x.values())
a. dict_values([4, 8, 16, 32])
b. dict_values{4, 8, 16, 32}
c. dict_values(4, 8, 16, 32)
d. dict_values[4, 8, 16, 32]
100. What will be the output after the following statements?x = {4:'Jan', 2:'Feb', 3:'March', 4:'April'}
print(x[2])
a. Jan
b. Feb
c. March
4. April
101, What will be the output after the following statements?
x = (0:4, 1:8, 2:16, 3:32)
print (list (x,values())[2])
a. [4, 8]
b. [4, 8, 16]
c. 16
a8
102, What will be the output after the following statements?
x = {0:4, 1:8, 2:16, 3:32}
print (x.items())
a. dict_items(4, 8, 16, 32)
b. dict_items([4, 8, 16, 32])
c. dict_items[0, 1, 2, 3]
d. dict_items([(0, 4), (1, 8), (2, 16), (3, 32)])
103, What will be the output after the following statements?x = (5:4, 8:8, 3:16, 9:32}
print(sorted(x, items()))
a. [4, 8, 16, 32]
b.[@, 16), 6, 4), (8, 8), 9, 32)]
c. 13, 5, 8, 9]
d. [(4, 5), (8, 8), (16, 3), (32, 9)]
104, What will be the output after the following statements?
x=7
if x>5
print(20)
aoe
XUN
“ So
105. What will be the output after the following statements?
x=8
if x>8
print(20)
else:
print(10)
a. 20
b.x
c. 10
4.8
106. What will be the output after the following statements?x = 40
if x > 10:
print(20)
elif x == 40:
print(10)
else:
print (30)
a. 20
b. 40
c. 10
d. 30
107. What will be the output after the following statements?
x = 15
if x > 15:
print (0)
elif x == 15:
print(1)
else:
print(2)
aogP
mREo
aR
108. What will be the output after the following statements?
x=5
if x > 18:
print('yes')
elif x == 15:
print (‘equal’)else:
print(‘no')
a.15
b. yes
c. equal
d. no
109. What will be the output after the following statements?
x = 50
if x > 10 and x < 15:
print('true')
elif x > 15 and x < 25
print(‘not true’)
elif x > 25 and x < 35
print('false')
else:
print('not false')
a. true
b. false
c. not true
d. not false
110, What will be the output after the following statements?
x = 25
if x > 10 and x < 15:
print('true')
elif x > 15 and x < 25
print('not true")
elif x > 25 and x < 35:
print('false')
els
print('not false')a. true
b. false
c. not true
d. not false
111. What will be the output after the following statements?
x = 15
if x > 10 and x <= 45:
print('true')
elif x > 15 and x < 25
print(‘not true’)
elif x > 25 and x < 35
print('false')
else:
print('not false')
a. true
b. false
c. not true
d. not false
112, What will be the output after the following statements?
x = 25
if x > 10 and x <= 15:
print('true')
elif x >= 15 and x < 25:
print('not true")
elif x >= 25 and x < 35:
print('false')
else:
print('not false')
a. trueb. false
c. not true
d. not false
113. What will be the output after the following statements?
x = 25
if x >= 10 and x <= 15
print('true')
elif x >= 15 and x <= 25:
print('not true’)
elif x >= 25 and x <= 3
print('false')
else:
print(‘not false’)
a. true
b. false
c. not true
d. not false
114. What will be the output after the following statements?
x = 20
if x <= 10 or x >= 75:
print(‘true’)
elif x <= 15 or x >= 55
print('not true’)
elif x <= 25 or x
print('false')
35:
els
print(‘not false’)
a. true
b. false
c. not trued. not false
115. What will be the output after the following statements?
x = 30
if x <= 10 or x >= 75:
print('true')
elif x <= 15 or x >= 55
print('not true")
elif x <= 25 or x >= 35
print('false')
els
print(‘not false’)
a. true
b. false
c. not true
d. not false
116. What will be the output after the following statements?
x = 80
if x <= 10 or x >= 75:
print(‘true')
elif x <= 15 or x >= 55
print(‘not true’)
elif x <= 25 or x >= 35
print('false')
else:
print('not false')
a. true
b. false
c. not true
d. not false117. What will be the output after the following statements?
x = 60
if x <= 10 or x >= 75:
print('true')
elif x <= 15 or x >= 55:
print('not true’)
elif x <= 25 or x >= 35
print('false')
else:
print(‘not false’)
a, true
b. false
c. not true
d. not false
118. What will be the output after the following statements?
x = 68
if x <= 50 and x >= 25:
print(‘true')
elif x <= 60 or x >= 55
print('not true’)
elif x <= 70 and x >= 35:
print('false')
else:
print(‘not false’)
a. true
b. false
c. not true
d. not false
119. What will be the output after the following statements?x = 99
if x <= 30 or x >= 100:
print('true')
elif x >= 50 and x <= 80:
print(‘not true’)
elif x >= 100 or x <= 75:
print('false')
else:
print('not false')
a. true
b. false
c. not true
d. not false
120, What will be the output after the following statements?
x = 70
if x <= 30 or x >= 100:
print('true')
elif x <= 50 and x
print('not true')
elif x >= 150 or x <= 75:
print('false')
else:
print('not false')
50:
a. true
b. false
c. not true
d. not false
121. What will be the output after the following statements?
x = 40
y = 25
if x + y >= 100:print('true')
elif x + y == 50:
print('not true')
elif x + y <= 90:
print('false')
else:
print('not false')
a. true
b. false
c. not true
d. not false
122. What will be the output after the following statements?
x1
while x < 10:
print(x, end="")
x=x td
23456789
al
bl
c. 10
d.2
123, What will be the output after the following statements?
x= 0
while x < 10:
print(x, end="")
x44
a. 0123456789
b. 123456789
c. 4123456789d. 048
124, What will be the output after the following statements?
x= 0
ya4
while x + y < 10:
print(x, end='')
x42.
a. 012345
b. 0123456789
c. 4123456789
d. 048
125. What will be the output after the following statements?
x= 0
ys4
while x + y < 10:
x45.
print(x, end="")
a. 012345,
b. 0123456
c. 123456,
d. 0123456
126, What will be the output after the following statements?
x=.
yr4
while x * y < 10:
print(y, end='')ytea
a. 012345,
b. 456789
c, 123456789
d. 0123456789
127. What will be the output after the following statements?
x=1
ys4
while x * y < 40:
print(y, end="")
x te 1
yts2
a4
b. 48
c. 148
d. 0123456789
128. What will be the output after the following statements?
xed
y=4
while x * y <= 10
print(x, end='")
x45.
yted
a4
b. 48
c. 14
d. 12129. What will be the output after the following statements?
x, y= 2, 5
while y - x <5:
print(x*y, end=" ')
x45 3
yte4
a. 1045
b. 10 45
c. 34
d.341045
130. What will be the output after the following statements?
x, y=, 1
while y < 10:
print(y, end=' ')
x Yay, x+y
a112358
b. 112358
c. 0123456789
d.02468
131. What will be the output after the following statements?
xe.
while x <4
x42.
ys.
while y <3:
print(y, en
yra1122
b.11223344
1234
d.121212
132. What will be the output after the following statements?
xeyel
while x <4
x +21
while y < 3:
print(y, end=" ')
ytei
a.1122
b.12
c.1234
d.121212
133. What type of loop is this?
xed
while x <5
print(x, end='")
a. Closed loop
b. One time loop
c. Infinite loop
d, Evergreen loop
134. What will be the output after the following statements?x = 'hello'
for i in x:
print(i, end='')
ah
b. hello
chello
dix
135. What will be the output after the following statements?
for i in range(5)
print(i, end='")
a5
b.15
c. 012345,
d. 01234
136. What will be the output after the following statements?
for i in range(1,5):
print(i, end='")
a.15
b. 12345
c. 1234
d. 012345
137. What will be the output after the following statements?for i in range(1,25,5):
print(i, end=" ')
a.16111621
b.15 1015 2025
c1525
d. 16111621
138. What will be the output after the following statements?
a.P
b. python
c. Pytho
d. Python
139. What will be the output after the following statements?
x= ('a', "bY, ‘et, 'd")
for iin x:
print(i, end=' ')
a. abcd
b.abed
c. False
d. True
140. What will be the output after the following statements?x= (x, 2", 'y}
for i in x:
print(i, end="")
axzy
b.xy
c. False
d, True
141. What will be the output after the following statements?
xs {'zr1', ty:2", 'x:3'}
for i in x:
print(i, end=" ')
axyz
b.123
©. x3 y:2 2:1
d. True
142. What will be the output after the following statements?
x= [PY ty, ttl, ht, fot, tiny
for i in enumerate(x):
print(i, end='")
a. (PICY)t)CH)Co')('n')
b. python
c. python
d. (0, 'P')(1, 'y')(2, 't’)(3, ‘h’\(4, 'o')(5, 'n')
143. What will be the output after the following statements?x= (xtsd, ty':2, '2":3}
for i in x:
print(i, end=' ')
axyz
b.123
c. x1 y:2 2:3
d. True
144. What will be the output after the following statements?
x= ('xtid, ty'r2, 12413}
for i, j in x.items():
print(i, j, end=' ')
axyz
b.xly2z3
cexLy:22:3
d.x, 1, y,2,2,3
145. What will be the output after the following statements?
ED tye tty hy fot, tnt]
y= ['0", "2", 12", 13", tat, '5"]
for iin zip(x, y):
print(i, end='')
a. (PYCy')(t)(Ch)(0')('n')
b. python 012345
©. Cp, Oy, ‘T(t "2)Ch, 390! '4C, 5)
d. (0, "P(A, 'y')(2, 't)(, 'b')(4, '0')(5, 'n')146, What will be the output after the following statements?
for i in range(1,5):
print(i, end="')
if i == 3:
break
a. 123
b, 1234
c. 12
d. 12345
147. What will be the output after the following statements?
for 4 an range(o,5):
if i ==
break
print(i, end="")
a.12
b. 01
c. 012
d. 0123
148. What will be the output after the following statements?
for 4 an range(2,5):
if i
continue
print(i, end=' ')
a124
b.1234
c12d.123
149. What will be the output after the following statements?
for i in range(0,5):
print(i, end='")
if i
continue
a, 0124
b. 01234
c. 12
d. 1345
150. What will be the output after the following statements?
myvar = 5
def printvar() :
print (myvar)
printvar()
a. 01245
b, 12345
a5
d. 1234
151. What is printvar in the following statements?
myvar = 5
def printvar() :
print(myvar)
printvar()a. A list
b. A string
c. An integer
d. A function
152. What will be the output after the following statements?
myvar = 5
def printvar() :
print(myvar, end ='')
printvar()
printvar()
pooe
huang
aa
153. What will be the output after the following statements?
def call(var)
print(var, end ='')
call(45)
paoge
aay
<
=
154. What will be the output after the following statements?
def call(vari, var2) :
print(vara + var2, end ="')call(10, 40)
a. 10
b. 50
c. 40
d. 10 + 40
155, What will be the output after the following statements?
def call(vara, var2, var3) :
print(var1 var2 var3, end ='')
a=b=c= 10
call(a, b, c)
a. 1000
b. 10
c. 30
d. 10 10 10
156. What will be the output after the following statements?
def call(var1=20, var2=5, var3=2)
print(var1 var2 var3, end ='')
call()
a. 100
b. 1000
c. 2052
d. 200
157. What will be the output after the following statements?def call(var1=20, var2=5, var3=2) :
print(var1 var2 var3, end ='')
call(5,9,7)
a. 597
b. 315
c. 2052
d, 200
158. What will be the output after the following statements?
def call(var1=20, var2=5, var3=2)
print(vara var2 var3, end ='')
call(5,7)
a. 57
b. 315
c. 70
d. 200
159. What will be the output after the following statements?
def call(var1=20, var2=5, var3=2)
print((var * var2) - var3, end ='')
call(var2=5, var3=3, vari=4)
a.17
b. 98
c. 70
did
160. What will be the output after the following statements?def call(var1=20, var2=5, var3=2)
print((var1 * var2) - var3, end ='')
call(7,4)
a.17
b. 98
c. 26
d. 11
161. What will be the output after the following statements?
def call(x, y) :
return x * y
print(call(5, 3))
162. What will be the output after the following statements?
def call(y, x) :
return x / y
z= call(4, 9)
print(z)
a. 0.444445
b.2
c0
d. 2.25163, What will be the output after the following statements?
def call(x,y)
if y =5 0:
return
return y - x
print (call(8,2))
paooP
6
6
2
6.0
164, What will be the output after the following statements?
def call(x,y) :
if x == 0:
return
return y + x
print(call(@,5))
as
b.5.0
c.0
d. None
165. What will be the output after the following statements?
y = lambda x: x*4
print(y(6))
a. 24
b. 24.0
24d. 36
166. What will be the output after the following statements?
¢.27
d. No output
167. Which of the following is not a core data structure in Python?
a. List
b. Module
c. Dictionary
d. Tuple
168, What will be the output after the following statements?
def gen():
x=0
while True
yield x
x +21
y = gen()
print(next(y), end='")
print(next(y), end='')
print(next(y), end='')
a. 012b. 123
e111
d. 000
169, What will be the output after the following statements?
def gen():
x=2
while True
yield x
x +21
y = gen()
for i
print(i, end="')
a. 0123
b. 123
c. 12345
d. 234
170, What do you type to enter the interactive help mode of Python?
a. HELP
b. save
c. help()
d. help
171. What does the following statement do?
import randoma. Imports the random module
b. Imports a random module from a list of modules
c. Imports the random function
d, imports the directory named random
172. What does the following statement do?
import keyword, sys
a. Imports all the python keywords
b. Imports the keyword and sys modules
c. Imports the keyword and sys functions
d. imports the directories named keyword and sys
173. What will be the output after the following statements?
import random as rd
print(rd.randint(4,7))
a. A random float value between 4 and 7, including 4 and 7
b. A random float value between 4 and 7, excluding 4 and 7
c. A random integer value between 4 and 7, excluding 4 and 7
d. A random integer value between 4 and 7, including 4 and 7
174. What will be the output after the following statements?
import random as rd
print(rd.random())
a. A random float value between 0 and 1
b. A random integer value between 0 and 1c. A random float value between 0 and 10
d. A random integer value between 0 and 10
175, What will be the output after the following statements?
from random import *
x = [0, 2, 4, 6, 8, 10]
print(sample(x, 3))
a. A dictionary containing 3 random keys from list x
b. Three random integer values between 0 and 10
c. A list containing 3 random elements from list x
d. A tuple containing 2 random elements from list x
176, Which of the following can be a possible output after the following
statements?
from random import *
print(sample(range(0,10), 3))
177. What does the following statements do?
import sys
print(sys.version)
a. Displays the Python version
b. Displays the operating system versionc. Displays the date
d. Displays the year
178. What does the following statements do?
import sys
print(sys. executable)
a. Displays the Python version
b. Displays the operating system version
c. Displays the location of the Python interpreter
d. Displays the date and time
179, What does the following statements do?
import keyword
print (keyword. kwlist)
a. Displays the list of Python modules
b. Displays a list of all the Python keywords
c. Displays a random keyword from the Python keywords
d. Displays the date and time
180. What will be the output after the following statements?
import math
print (math. floor (67.3) )
a. 67
b. 68
c. 67.0
d. 68.0181. What will be the output after the following statements?
import math
print(math.ceil(21.4))
a, 21
b. 22
c. 21.0
d. 22.0
182. What will be the output after the following statements?
import math
print(math.sqrt(4))
ANNN
so
183. What will be the output after the following statements?
import math
print(math.pow(3,2))
aooPp
CRD
es184, What does the following statements do?
import datetime
print (datetime.datetime. today())
a. Displays current date and time
b. Displays a list of all the hours remaining till midnight
c. Displays a random time from today's date
d. Displays today's weekday name
185. What does the following statements do?
from datetime import *
print(getattr(datetime.today(), 'hour'))
a. Displays current date and time
b. Displays a list of all the hours remaining till midnight
c. Displays current hour of the day
d. Displays the number of hours in a day
186. What does the following statements do?
from datetime import *
print (getattr(datetime.today(), 'year'))
a. Displays current date and year
b. Displays current year
c. Displays the number of months ina year
d. Displays the number of days in a year
187. What does the following statements do?from datetime import *
print(datetime. today().strftime('%A'))
a. Displays the full month name
b. Displays the abbreviated month name
c. Displays the abbreviated day name
d. Displays the full weekday name
188. What does the following statements do?
from datetime import *
print (datetime. today().strftime('%B'))
a. Displays the full weekday name
b. Displays the full month name
c. Displays the abbreviated day name
d. Displays the abbreviated month name
189. What does the following statements do?
from datetime import *
print (datetime, today().strftime('%d'))
a. Displays the hour number of 12-hour clock
b. Displays the date and time appropriate for locale
c. Displays the day of the month number (from 01 to 31)
d. Displays the microsecond number (from 0 to 999999)
190. What does the following statements do?
from datetime import *print (datetime, today().strftime('%c'))
a. Displays the date and time appropriate for locale
b. Displays the microsecond number (from 0 to 999999)
c. Displays the hour number of 12-hour clock
d. Displays the hour number of 24-hour clock
191. What does the following statements do?
from datetime import *
print(datetime, today().strftime('%f'))
a. Displays the date and time appropriate for locale
b. Displays the microsecond number (from 0 to 999999)
c. Displays the hour number of 24-hour clock
d. Displays the hour number of 12-hour clock
192. What does the following statements do?
from datetime import *
print(datetime, today().strftime('%I'))
a. Displays the hour number of 12-hour clock
b. Displays the minute number from 00 to 59
c. Displays the hour number of 24-hour clock
d. Displays the day number of the year from 000 to 366
193. What does the following statements do?
from datetime import *
print(datetime, today().strftime( '%H'))a. Displays the minute number from 00 to 59
b. Displays the hour number of 12-hour clock
c. Displays the hour number of 24-hour clock
d. Displays the day number of the year from 000 to 366
194. What does the following statements do?
from datetime import *
print (datetime, today().strftime('%j'))
a. Displays the month number from 01 to 12
b. Displays the minute number from 00 to 59
c. Displays the day number of the year from 000 to 366
d. Displays the second number from 00 to 59
195. What does the following statements do?
from datetime import *
print (datetime, today().strftime('%M'))
a. Displays the month number from 01 to 12
b. Displays the second number from 00 to 59
c. Displays the AM or PM equivalent for locale
d. Displays the minute number from 00 to 59
196. What does the following statements do?
from datetime import *
print(datetime, today().strftime('xm'))
a. Displays the minute number from 00 to 59b. Displays the month number from 01 to 12
c. Displays the second number from 00 to 59
d. Displays the AM or PM equivalent for locale
197. What does the following statements do?
from datetime import *
print (datetime. today().strftime('%p'))
a. Displays the AM or PM equivalent for locale
b. Displays the minute number from 00 to 59
c. Displays the month number from 01 to 12
d. Displays the second number from 00 to 59
198. What does the following statements do?
from datetime import *
print (datetime. today().strftime('%S'))
a. Displays the AM or PM equivalent for locale
b. Displays the second number from 00 to 59
c. Displays the week number of the year from 00 to 53
d. Displays the month number from 01 to 12
199. What does the following statements do?
from datetime import *
print (datetime, today().strftime('%w'))
a. Displays the weekday number from 0(Sunday) to 6(Saturday)
b. Displays the AM or PM equivalent for locale
c. Displays the date appropriate for localed. Displays the week number of the year from 00 to 53
200. What does the following statements do?
from datetime import *
print (datetime, today().strftime( 'xw'))
a. Displays the week number of the year from 00 to 53
b. Displays the date appropriate for locale
c. Displays the weekday number from 0(Sunday) to 6(Saturday)
d. Displays the time appropriate for locale
201. What does the following statements do?
from datetime import *
print (datetime. today().strftime( '%x'))
a. Displays the time appropriate for locale
b. Displays the current year as 00 to 99
c. Displays the current year as 0001 to 9999
d. Displays the date appropriate for locale
202. What does the following statements do?
from datetime import *
print (datetime, today().strftime('%x"))
a. Displays the current year as 0001 to 9999
b. Displays the timezone name
c. Displays the time appropriate for locale
d. Displays the current year as 00 to 99203. What does the following statements do?
from datetime import *
print (datetime. today().strftime('%y'))
a. Displays the current year as 00 to 99
b. Displays the current year as 0001 to 9999
c. Displays the timezone name
d. Displays the timezone offset from UTC as +HHMM or -HHMM.
204, What does the following statements do?
from datetime import *
print (datetime. today().strftime('%Y'))
a. Displays the current year as 0001 to 9999
b. Displays the timezone name
c. Displays the timezone offset from UTC as +HHMM or -HHMM
d. Displays the full month name
205. What does the following statements do?
from datetime import *
print (datetime. today().strftime('%z'))
a. Displays the timezone offset from UTC as +HHMM or -HHMM
b. Displays the timezone name
c. Displays the abbreviated month name
d. Displays the full month name
206. What does the following statements do?from datetime import *
print (datetime. today().strftime('%z'))
a. Displays the full month name
b. Displays the abbreviated month name
c. Displays the abbreviated day name
d. Displays the timezone offset from UTC as *+HHMM or -HHMM
207. What does the following statements do?
from datetime import *
print(datetime. today().strftime('wa'))
a. Displays the full month name
b. Displays the full day name
c. Displays the abbreviated day name
d. Displays the abbreviated month name
208. What does the following statements do?
from datetime import *
print (datetime, today().strftime( '%b'))
a. Displays the full month name
b. Displays the abbreviated month name
c. Displays the full day name
d. Displays the abbreviated day name
209. What does the following statements do?
from time import *print(time())
a. Displays the current time in seconds since the Epoch as a floating point
number
b. Displays the current time in minutes since the Epoch as a floating point
number
c. Displays the current time in seconds since the Epoch as an integer
d. Displays the current time in minutes since the Epoch as an integer
210. What does the following statements do?
from time import *
sleep(3)
a. Pauses the execution of the program by 3 minutes
b. Pauses the execution of the program by 3 seconds
c. Displays the current time in seconds since the Epoch as an integer
d. Displays the current time in minutes since the Epoch as an integer
2
1. What will be the output after the following statements?
x = ‘Python!
y = 'MCQ'
print(x + y)
a. Python Python
b. MCQMCQ
c. Python MCQ
d. PythonMCQ
212. What will be the output after the following statements?x = "Python '
print (x*3)
a. Pyt Pyt Pyt
b.t
c. Python Python Python
d. PythonPythonPython
213. What will be the output after the following statements?
x = "Python '
print (x[4])
h
t
Python Python Python Python
eaogp
0
214. What will be the output after the following statements?
x = "Python!
print (x[2:4])
a. Pyth
bith
c, tho
d. thon
215. What will be the output after the following statements?
x = 'Python'
print(x[:]). Pn
¢. Python
d. PythonPythonPython
216. What will be the output after the following statements?
x = 'Python'
print('y' in x)
217. What will be the output after the following statements?
x = 'Python'
print("p' not in x)
218. What will be the output after the following statements?
x = '{} 3 {}'.format('Python', 'Test')
print(x)a. Python 3 Test
b. Python Test
c. Test 3 Python
d. Test Python
219. What will be the output after the following statements?
x = '{1} for {0}'.format('Python', ‘Questions’ )
print(x)
a. Python for Questions
b. Questions for Python
c. 1 for 0
d. Python 1 for 0 Questions
220. What will be the output after the following statements?
x = '%s MCQ %s' %('Python', ‘Test')
print(x)
a. Python MCQ
b. MCQ Test
c. Test MCQ Python
d. Python MCQ Test
221. What will be the output after the following statements?
x = 'Python %d Version’ %(3)
print (x)
a. Python 3
b.3 Versionc. Python 3 Version
d. Python Version 3
222, What will be the output after the following statements?
x = 'Python %c or Python %c' %('2', '3')
print(x)
a. Python 3 or Python 2
b. Python 2 or Python 3
c. Python 2 or Python 2
d. Python 23
223, What will be the output after the following statements?
X = "Python %.1f or Python %.2f' %(2.7, 3.51)
print(x)
a. Python 3.51 or Python 2.7
b. Python 2 or Python 3
c. Python 2.7 or Python 3.5
d. Python 2.7 or Python 3.51
224, What will be the output after the following statements?
x = 'Python'
print(x.capitalize())
a. Python
b. Python.capitalize
c. PYTHON
d. pYTHON225. What will be the output after the following statements?
x = ‘python job interview!
print(x.title())
a. python job interview
b. Python job interview
c. Python Job Interview
d. Python job Interview
226. What will be the output after the following statements?
x = ‘python jobs'
print (x.upper())
a. PYTHON JOBS
b. Python jobs
c. Python Jobs
d. python jobs
227. What will be the output after the following statements?
x = ‘python jobs!
print (x.lower())
a. PYTHON JOBS
b. Python jobs
c. Python Jobs
d. python jobs228. What will be the output after the following statements?
x = 'Python Jobs'
print (x.swapcase())
a. PYTHON JOBS
b. pYTHON jOBS
c. Python Jobs
d. python jobs
229, What will be the output after the following statements?
x = 'Python'
print (x.join('33"))
a. Python33
b. 3Python3
c. Python3
d. Python 33
230. What will be the output after the following statements?
x = 'Python Test!
print (x.join('33"))
a. 3Python Test3
b. 3Python3Test
c. Python3Test3
d. Python Test33
231. What will be the output after the following statements?x = ' Python '
y= '3"
print(x.1strip()+y-1strip())
a. Python 3
b. 3Python3
c. Python3
d. Python+3
232. What will be the output after the following statements?
x = 'python '
y='3?
print(x.rstrip()+y.rstrip())
a. Python 3
b. 3Python3
c. Python3
d. Python+3
233. What will be the output after the following statements?
x = ' python *
ye'3'
Z = ' Questions '
print(x.strip()+y.strip()+z.strip())
a. Python 3 Questions
b. Python3Questions
c. Python3 Questions
d. Python 3Questions234, What will be the output after the following statements?
x = "Interview!
print(x.replace('e',' '))
a. Interview
b, Intrviw
c Interview
d. Int rvi w
235. What will be the output after the following statements?
x = 'MCQs!
print(x.1just(10, '*'))
a. MCQs*ee
b.MCQS
c. HMEMCQS
d.MCQs
236. What will be the output after the following statements?
x = 'MCQs!
print(x.rjust(10, '*'))
a. MCQs*e
b.MCQS
c. *EMCQS
d.MCQs
237. What will be the output after the following statements?x = 'MCQs"
print(x.center(10,'*'))
a. MCQs**e
b.MICQs*
cee MICOS
d.MCQs
238, What will be the output after the following statements?
x = "Python Pi Py Pip’
print (x.count('p'))
aoe
who
239, What will be the output after the following statements?
x = "Python Pi Py!
print (x.find('p'))
aogP
wow
240. What will be the output after the following statements?
x = "Python Pi Py!print(x.find('P'))
paooP
wow
241, What will be the output after the following statements?
x = 'Pi Py Python!
print(x.startswith('p'))
rue
False
al
b.o
eT
d.
242, What will be the output after the following statements?
x = 'Pi Py Python'
print(x.endswith('n'))
243, What will be the output after the following statements?
x = "Python!
print(x,isalpha())244. What will be the output after the following statements?
x = "Python 3°
print (x.isnumeric())
245. What will be the output after the following statements?
x = 'Python 3 McQ!
print(x,isalnum())
246, What will be the output after the following statements?
x = 'Python 3 McQ!
print(x,islower())
a. True‘alse
aos
orn
247. What will be the output after the following statements?
x = 'Python 3 MCQ'
print(x.istitle())
a. True
b. False
al
do
248. What will be the output after the following statements?
x = 'MCQ!
print (x.isupper())
a. True
b. False
al
do
249. What will be the output after the following statements?
x= '\nt
print (x.isspace())
a. True
b. False
ald.0
250. What will be the output after the following statements?
x = '2000'
print(x.isdigit())
a. True
b. False
cl
d.
251. What will be the output after the following statements?
x= '2.7'
print(x.isdecimal())
a. True
b. False
cl
d.
252. What does the following statement do?
x = open('python.csv', 'r')
a. Opens an existing text file named python.csv to write
b. Opens an existing text file named python.csv to append
c. Opens an existing text file named python.csv to read
d. Opens a new file named python.csv to read253. What does the following statement do?
Xx = open('python.csv', 'w')
a. Opens or creates a text file named python.csv to write
b. Opens or creates a text file named python.csv to append
c. Opens or creates a text file named python.csv to read
d. Opens a new file named python.csv to write
254. What does the following statement do?
X = open('python.csv', 'a')
a. Opens or creates a text file named python.csv to write
b. Opens or creates a text file named python.csv to append
c. Opens or creates a text file named python.csv to read
d. Opens a new file named python.csv to append
255. What does the following statement do?
x = open('python.txt', 'r+')
. Opens a text file named python.txt to read from or write to
. Opens a text file named python.txt to read
. Opens a text file named python.txt to write
|. Opens a new file named python.txt to append
angoe
256. What does the following statement do?
X = open('python.txt', 'w+')a. Opens a text file named python.txt to read
b. Opens a text file named python.txt to write to or read from
c. Opens a text file named python.txt to write
d. Opens a new file named python.txt to append
257. What does the following statement do?
X = open('python.txt', ‘at')
a. Opens a text file named python.txt to read
b. Opens a text file named python.txt to read and write
c. Opens a text file named python.txt to write to
d. Opens or creates a text file named python.txt to read from or write to at the
end of the file
258. What does the following statement do?
X = open('python.bat', 'rb')
a. Opens an existing text file named python.bat to write
b. Opens an existing binary file named python.bat to write
c. Opens an existing binary file named python.bat to append
d. Opens an existing binary file named python.bat to read
259. What does the following statement do?
X = open('python.bat', 'wb')
a. Opens or creates a binary file named python.bat to writeb. Opens or creates a binary file named python. bat to append
c. Opens or creates a binary file named python.bat to read
d. Opens a new file named python. bat to write
260. What does the following statement do?
X = open('python.bat', ‘ab')
a. Opens or creates a binary file named python. bat to write
b. Opens or creates a binary file named python.bat to append
c. Opens or creates a binary file named python.bat to read
d. Opens a new file named python. bat to append
261. What will be the output after the following statements?
Xx = open('python.txt', 'r')
print (x.name)
a. python
b. python.txt opened
c. python.txt or FileNotFoundError
d. python r
262. What will be the output after the following statements?
x = open('python.csv', 'w')
print (x.mode)
a. python write
b. python.txt
crd.w
263. What will be the output after the following statements?
x = open('python.csv', 'w')
print(x.closed)
a. open
b. closed
c. True
d. False
264, What will be the output after the following statements?
X = open('python.csv', 'w')
x.close()
print(x.closed)
a. open
b. closed
c. True
d. False
265. What will be the output after the following statements?
x = open('python.csv', 'w')
print(x.readable())
a. readable
b. writable
c. True
d. False266. What will be the output after the following statements?
X = open('python.csv', 'w!)
print(x.writable())
a, readable
b. writable
c. True
d. False
267. What will be the output after the following statements?
X = open('python.csv', 'a')
print(x.writable())
a, readable
b. writable
c. True
d. False
268. In IDLE shell, the output will be the same for all the following statements
except one. Which one?
a. 4+4
b4+4
c. 4*2
d. 4**2
269. In IDLE shell, what is the keyboard shortcut for the previous command in
history on Windows/Linux?
a. Page Downb. Page Up
c. Alt+ P
d. Curl +P
270. In IDLE shell, what is the keyboard shortcut for the next command in
history on Windows/Linux?
a. Page Down
b. Page Up
c. Ctrl +N
d. Alt+N
271. In IDLE shell, what is the keyboard shortcut for the previous command in
history on Mac OS X?
a. Page Down
b. Page Up
c. Alt +P
d. Cul +P
272. In IDLE shell, what is the keyboard shortcut for the next command in
history on Mac OS X?
a. Page Down
b. Page Up
c. Cl +N
d. Alt+N
273. In IDLE file editor, what is the keyboard shortcut for executing the program
in shell?
a. FS
b. FL
c. Shift
d. Alt274. What type of error is shown when you use a variable without assigning an
initial value?
a. Not declared
b. Not defined
c. Not assigned
d. Not a variable
275. What type of language is Python?
a. High level
b. Low level
c. Top level
d. Bottom level
276. Python language was named after?
a. Python - the reptile
b. Monty Python
c. A pet
d. A company
277. Who is the creator of Python?
a. Bill Gates
b. Guido Van Rossum
c. Jeff Bezos
d. Larry Page
278. Which of the following is identified with Python?
a. Dynamic typing
b. Static typing
c. Slow typing4. Auto typing
279. Which of the following is used to enclose strings?
a. Single quotes
b. Double quotes
c. Either single quotes or double quotes
d.! symbol
280. Which of the following is used to add an invisible tab character to the
output?
a. \t
b. \tab
cla
d.\b
281. What will be the output after the following statement?
print('2\\ta")
a2t4
b. 2\t4,
c.24
d. 2 tab 4
2
8
2. What will be the output after the following statements?
True
False
5 if (a == 1) else b
rint(c)
a
b
c
Pp283. What will be the output after the following statements?
a = True
b = False
c= 'a' if (b == 0) else 'b’
print(c)
a. True
b. False
ca
db
284, What will be the output after the following statements?
a = False
b = False
print(a and b)
a. True
b. False
cab
d.ba
285. In the order of precedence, which of the operation will be completed first in
the following statement?
3*64+5-4/2a. Multiplication
b. Division
c. Addition
d. Subtraction
286. In the order of precedence, which of the operation will be completed last in
the following statement?
3*6+5-4/2
a. Multiplication
b. Division
c, Addition
d. Subtraction
287. What will be the order of precedence of operations in the following
statement?
w*4-14+8/5
a. Multiplication, Division, Subtraction, Addition
b. Multiplication, Division, Addition, Subtraction
c. Division, Multiplication, Subtraction, Addition
d. Division, Multiplication, Addition, Subtraction
288. What will be the data type of x after the following statement if input entered
is 64?
x = float(input('Enter a number: '))a. Integer
b. String
c. List
d. Float
289. What will be the output after the following statements?
a= 27/3%2* 4**2
print(a)
a0
b. 16.0
c. 32
d. 4.0
290. What will be the output after the following statements?
a=3/3 47 - 3*3
print(a)
a. 20.0
b. 1.0
c. 36.0
d. 0.0
291. What will be the output after the following statements?
a = [1,3,5,7,9,11,13,15,17,19]
print(a[1:5],a[3:17])
3,5, 7, 9, 11, 13, 15, 17]al (7,9, 11, 13, 15, 17, 19]
4.[3, , 11, 13, 15, 17, 19]
292, What will be the output after the following statements?
a = [1,3,5]
print(a * 2)
293. Which of the following is not a valid variable name?
a. abe
b. abc123
c. 123abe
d. abe_123
294. Which of the following is a valid variable name?
a. a$1
bal
cla
d. abe 123
295. What will be the output after the following statements?
15
a
25
rint (a,b)
a
b
a
pia. 25 15
b. 15 25
c.alS
d.25a
296. What will be the output after the following statements?
x=16/4*5
y=16/4*5.0
z2=16/4.0*5
print(x, y, 2)
a. 25 15 20
b. 20.0 20.0 20.0
c. 20.0 20 20.0
d. 20 20.0 20
297. What will be the data type of x after the following statement?
x = 1/2
a. Integer
b. List
c. String
d. Float
298. What will be the output after the following statements?
def x(y,z):
pass
x(1,4)a. 14
b. yz
c. No output
d. None
299. What will be the output after the following statements?
bea
for a in range(1, 10, 3):
bisati
print(b)
a. 14
b. 16
c. 20
d. 25
300. What will be the output after the following statements?
bea
for a in range(1, 10):
be=a-1
print(b)
a. 37
b. 47
c. 44
d. 38
301. What will be the output after the following statements?for a in range(10, 1):
b-sati
print(b)
poge
owAN
302. What will be the output after the following statements?
bea
for a in range(1, 5)
btsati
print(b)
a, 120
b. 40
c. 36
d. 250
303. What will be the output after the following statements?
a = True
print(a and not a)
aa
b. False
c.nota
d. True
304. What will be the output after the following statements?a = True
b = False
print(a =
b or not b)
305. What will be the output after the following statements?
a = 'Hello'
b = ‘hello’
print(a is b)
a.aisb
b. False
c. not b
d. True
306. What will be the output after the following statements?
"python!
"python!
rint(a is b)
a
b
pi
a.aisb
b. False
¢. not b
d. True
307. What will be the output after the following statements?a= [4, 7, 9]
b= [4, 7, 9]
print(a is b)
a.aisb
b. False
c. not b
d. True
308. What will be the output after the following statements?
a= [4, 7, 9]
b=[7, 4, 9]
print(a is not b)
a.aisb
b. False
c. not b
d, True
309. What will be the output after the following statements?
a= [3, 6, 9]
b = [3, 6, 9)
print(a is b, a
a. True True
b. False False
c. False True
d. True False310. What will be the output after the following statements?
wununn
ocpao
8
ypocmoce
a
rint(a, b, c)
a.0510
b.5 1010
c.5105
d.5510
311. What will be the output after the following statements?
15
20
b
©
a
print(b, c)
b
ce
a
b
c
312. In IDLE shell, the output will be the same for all the following statements
except one. Which one?
a. 4*3,
b. 60/5
c.17-5
d. 12/1313. In IDLE shell, the output will be an error for one of the following
statements. Which one?
a. P ='python' * int('1')
b. P='python' + 1
c. P= 'python' + str(1)
‘python’ * 1
314. What will be the output after the following statements?
as ang
b = pow(4,3)
print(a, b)
aad
b.43
c. 1212
d. 64.64
315. What will be the output after the following statements?
a= min(10, 15, 6, 17, 24)
print(a)
(10, 15, 6, 17, 24)
6
5
2.
a.
b.
c
d. 24
316. What will be the output after the following statements?a= [4, 25, 16, 9, 24]
print(max(a))
a. [4, 25, 16, 9, 24]
b.9
c. 2!
d.2.
RG
317. What will be the output after the following statements?
a = round(5.3)
b = round(5.6)
c = round(5.5)
print(a, b, c)
a555
b.656
e566
d.565
318. How many times will "Python 3" be printed after the following statements?
for i in range(1, 5)
print('Python 3")
Boge
aunRw
319. What will be the output after the following statements?a = round(4.49999)
print (a)
aoe
pRUR
ns
320. What will be the output for a function that does not return any value?
a. None
b. No value
c. Zero
d. Bool
321. What type of error will be shown after the following statement?
a=b
a. SyntaxError
b. TypeError
c. ValueError
d, NameError
322. What type of error will be shown after the following statement?
a = int(‘hello')
a. SyntaxError
b. TypeError
c. ValueError
d. NameError323. What type of error will be shown after the following statement?
a= {7)
a. SyntaxError
b. TypeError
c. ValueError
d. NameError
324. What type of error will be shown after the following statement?
a= 'Python' +3
a. SyntaxError
b. TypeError
c. ValueError
d. NameError
325. What is the data type of a after the following statement?
a. List
b. Dictionary
c. Tuple
d. Set
326. What is the data type of a after the following statement?a. List
b. Dictionary
c. Tuple
d. Set
327. What is the data type of a after the following statement?
a= (1, 4, 3, 6)
a. List
b. Dictionary
c. Tuple
d. Set
328, What is the data type of a after the following statement?
a=[1, 4, 3, 6]
a. List
b. Dictionary
c. Tuple
d. Set
329. What is the data type used to store values in key values pair?
a. List
b. Dictionary
c. Tuple
d. Set330. In IDLE shell, which of the following statements gives SyntaxError?
a. "Python\tis\tEasy\n"
b. "Hello, it's very easy to learn Python”
c. "Python", "easy"
d. "Python is easy’
331, What will be the output after the following statements?
45
55
= (a+b) /2
rint(c)
a
b
c
pI
332. Which of the following has the highest precedence in an expression?
a. Parentheses
b. Exponential
c. Division
d. Subtraction
333. What will be the output after the following statements?
a = 4*3**2
print(a)
a. 32b. 144,
c. 36
d. 24
334, What is the name of Python's built-in module for regular expressions?
a. regex
b. regexes
c. REG
dre
335, What is the name of Python's built-in module for delimited files?
a. csv
b. tsc
c, delimited
d. pipe
336, What is the name of Python's built-in module for basic date and time types?
a. date
b. time
c. datetime
d. dates
337. What is the name of Python's built-in module for email related tasks?
a. mailserver
b. email
c. message
d. mail
338, What is the name of Python's built-in module for reading passwords?
a. getpassb. password
c. login
d. readpass
339. What is the name of Python's built-in module for IPv4/IPv6 manipulation?
a. getip
b. ipman
c. ip
d. ipaddress
340. What is the name of Python's built-in module for encoding/decoding JSON
format?
a. json
b. jeode
c. jsonencode
d. jsoncode
341, What is the name of Python's built-in module for Python keywords?
a. string
b. keyword
c. stringtest
d. keytest
342. What is the name of Python's built-in module for mathematical functions?
a. maths
b. mathematics
cc. math
d. mathfunc
343. What is the name of Python's built-in module for operating system
intarfaroc?a. windows
b. Tiunx
c. operatingsystem
d.os
344, What is the name of Python's built-in module for data pretty printer?
a. pprint
b. print
c. prettyprint
d. printp
345, What is the name of Python's built-in module for generating pseudo-random
numbers?
a. psrandom
b. random
c. psuedo
d. randomnum
346, What is the name of Python's built-in module for general purpose event
scheduler?
a. scheduler
b. eventsched
c, sched
d. schedule
347. What is the name of Python's built-in module for high level file operations?
a. shutil
b. fileutil
c. futility
d. fileop348, What is the name of Python's built-in module for low level networking
interface?
a. net
b. socket
c. webking
d. webworking
349. What is the name of Python's built-in module for SQLite databases?
a. SQL
b. sqldb
c. dbase
d. sqlite3
350. What is the name of Python's built-in module for TLS/SSL wrapper for
socket objects?
a. ssl
b. swrap
c.tlsssl
4. sslobj
351. What is the name of Python's built-in module for mathematical statistics
functions?
a. mathstats
b. statistics
c. statmath
d. statfunc
352. What is the name of Python's built-in module for subprocess management?
a. subb. mansub
c. submng
d. subprocess
353. What is the name of Python's built-in module for Python's configuration
information?
a. config
b. pysys
c. sysconfig
d. pycon
354. What is the name of Python's built-in module for telnet client class?
a, telnetlib
b. tellib
c. tet
d. telnet
355. What is the name of Python's built-in module for generating temporary files
and directories?
a. temp
b. tempdir
c. temporary
d. tempfile
356. What is the name of Python's built-in module for thread based parallelism?
a. thread
b, threadall
c. threading
. thrpar
357. What is the name of Python's built-in module for time access andconversions?
a. timely
b. time
c. primetime
d. mytime
358. What is the name of Python's built-in module for working with calendars?
a, calendars
b. calendar
c. yearcal
d. calc
359. What is the name of Python's built-in module for measuring execution time
of code snippets?
a. timeit
b. selftime
c. codetime
d. timer
360. What is the name of Python's built-in module for interface to Tcl/Tk for
graphical user interfaces?
a. tkgui
b. guitk
c. intertk
d. tkinter
361. What is the name of Python's built-in module for simple educational
graphical applications?
a. torque
b. teduc. wrue
d. moveturtle
362. What is the name of Python's built-in module for url handling?
a. urls
b. urllib
c. URL
d. httpurl
363. What is the name of Python's built-in module for interface to WAV sound
format?
a. wav
b. WAVE
c. WAV,
d. wave
364, What is the name of Python's built-in module for web browser controller?
a. browser
b. browse
c. webrowser
d. webbrowser
365, What is the name of Python's built-in module for xml processing?
a. xml
b. XML
c. allxml
d. onlyxml
366. What is the name of Python's built-in module for reading and writing ZIP
archive files?a. readzip
b. zipfile
c. writezip
d. rwzip
367, What is the name of Python's built-in module for running Python scripts via
CGI?
a. pcgi
b. pycgi
©. cgi
d. cgipy
368. What is the name of Python's built-in module for mathematical functions
for complex numbers?
a, complexmath
b. math
c. mathe
d. mathplex
369. What is the name of Python's built-in module for conversions between color
systems?
a. color
b. colors
c. colours
4. colorsys
370. What is the name of Python's built-in module for shallow and deep copy
operations?
a. copyd
b. copyme
c. copy
d. copys371. What is the name of Python's built-in module for comparing files?
a. filecmp
b. cmpfile
c. compare
d. filecompare
372. What is the name of Python's built-in module for FTP protocol client?
a. ftp
b. ftplib
c. FIP
d. pftp
373, What is the name of Python's built-in module for unix style pathname
pattern expansion?
a. upattern
b. pathpat
c. upath
d. glob
374, What is the name of Python's built-in module for html manipulation?
a. hyper
b. xml
c. hum
d. uml
375. What will be the output after the following statements?
x= [5, 4, 3, 2, 4]
x.clear()print(x)
a. [0, 1, 2,3, 4, 5]
b. [0]
el
d. [1, 2, 3, 4, 5]
376, What will be the output after the following statements?
[5, 4, 3, 2, 1]
y = x.copy()
print(y)
377. What will be the output after the following statements?
x=
for i in range(19):
x.append(i**2)
print(x)
378. What will be the output after the following statements?x = list(map(lambda x:x**2, range(5)))
print(x)
379. What will be the output after the following statements?
x = [i**2 for i in range(4)]
print(x)
380. What will be the output after the following statements?
a = [(x, y) for x in [, 1, 2] for y in [3, 4, 5] if x!=y]
print(a)
a. [0, 1, 2, 3, 4, 5]
b. [(1, 3), (L, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
c. [(0, 1, 2), (3, 4, 5)]
d. [(0, 3), (0, 4), (0, 5), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
381. What will be the output after the following statements?
a = [(x, y) for x in [, 3, 5] for y in [5, 4, 0] if x!=y]
print(a)a. [(0, 5), (0, 4), (3, 5), (3, 4), (3, 0), (5, 4), (5, 0)]
b. [(1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
c. [(0, 3, 5), (0, 4, 5)]
. [(0, 5), (0, 4), (0, 0), (3, 5), (3, 4), (3, 0), (5, 5), (5, 4), (5, OD]
382. What will be the output after the following statements?
a =[(x, y) for x in [0, 2] for y in [2, 4, 0] if x==y]
print(a)
a. [(0, 2)]
b. [(0, 0), (2, 2)]
c. [(0, 2), (2, 4, 0)]
d. [(0, 2), (0, 4), (0, 0), (2, 2), (2, 4), (2, 0)]
383. What will be the output after the following statements?
a= [(x, y) for x in [0, 2] for y in [2, 4, 0] if x!=y]
print(a)
a. [(0, 2)]
b. [(0, 0), (2, 2)]
c. [(0, 2), (0, 4), (2, 4), (2, 0))
d. [(0, 2), (0, 4), (0, 0), (2, 2), (2, 4), (2, 0)]
384, What will be the output after the following statements?
a=(]
for x in [0, 1, 2]:
for y in [3, 4, 5]:
if x!=y:a-append((x,y))
print(a)
a. [0, 1, 2,3, 4, 5]
b.[G, 3), , 4), (, 5), 2,3), 2, 4), 2, 5)]
c.[(, 1, 2), 3, 4, 5)]
d. [(0, 3), (0, 4), (0, 5), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)
385. What will be the output after the following statements?
a= [-2, -1, 0, 1, 2]
print([i**3 for i in a])
a. [(0, 2)]
b.[-2, -1, 0, 1, 2]
c. [8, 1, 0, 1, 8]
d. [-8, -1, 0, 1, 8]
386. What will be the output after the following statements?
a=[-3, -1, 0, 1, 3]
print([i**4 for i in a])
a. (81, 1, 0, 1, 81]
b. [-81, -1, 0, 1, 81]
c. [16, 1, 0, 1, 16]
d. [-16, -1, 0, 1, 16]
387. What will be the output after the following statements?
a=[-3, -1, 0, 1, 3]
print([x for x in a if x>=0])388. What will be the output after the following statements?
a= [-3, -1, 0, 1, 3]
print([abs(x) for x in a])
a. [-3, -1, 0, 1,3]
b. [0, 1, 3]
c. [3, 1,0, 1, 3]
d.[-1,0, 1]
389. What will be the output after the following statements?
a= [' today', ' tomorrow
print([x.strip() for x in a])
"not now']
a. ['‘today’, ‘tomorrow ’, ‘not now’)
b. [' today’, ' tomorrow’, ‘not now’]
c. ['today’, 'tomorrow’, 'notnow']
d. [‘today’, ‘tomorrow’, 'not now']
390. What will be the output after the following statements?
print([(x, x*2) for x in range(4)])a. [(0, 0), (1, 2), (2, 4), (3, 6))
b. [(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)]
c. £1, 2), (2, 4), (3, 6), (4, 8)]
d. [(1, 2), (2, 4), (3, 6)]
391. What will be the output after the following statements?
a= [[0, 1, 2], [7, 8, 9], [4, 5, 6]]
print([x for y in a for x in y])
392. What will be the output after the following statements?
from math import pi
a = [str(round(pi, i)) for i in range(0,5)]
print(a)
a. [3.0, 3.1, 3.14, 3.142, 3.1416]
b. ['3.0,,'3.1, '3.14!, '3.142']
c.['3.0', 3.1, '3.14, 3.142’, '3.1416)]
d. ['3.1', '3.14', '3.142', '3.1416)]
393. What will be the output after the following statements?
a= [[9, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
b = [[x[i] for x in a] for i in range(4)]
print(b)a. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
b. (10, 4, 8], (1, 5, 9], b, 6, 10}, (3, 7, 11]
c. [[0, 1, 21, [3, 4, 5], [6, 7, 81, [9, 10, 111]
d. [0, 1, 2, 3], [4, 5, 6, 1B. 9, 10, 11]
394. What will be the output after the following statements?
a= {]
b = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
for i in range(4):
a.append([row[i] for row in b])
print(a)
a. [0, 1, 2, 3, 4, 5, 6, 9, 10, 11]
b. [[0, 4, 8}, [1, 5, 9], ia 6, 10], [3, 7, 11]]
c. [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11}]
d. [0, 1, 2, 3], [4, 5, oe [8, 9, 10, 11]
395. What will be the output after the following statements?
a= [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 19, 11]
print(list(zip(*a)))
a. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
b. [[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11]]
c. [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11])
d. [0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]
396. What will be the output after the following statements?
a= [0, 1, 2, 3]
del a
print(a)a. None
b. Null
c.[0, 1, 2,31
d. NameError
397. What will be the output after the following statements?
a= [0, 1, 2, 3]
del a[:]
print(a)
a. None
bo
c.[0, 1, 2, 3]
d. NameError
398, What will be the output after the following statements?
x = [i*2-4 for i in range(5)]
print(x)
a. [0, 1, 2, 3, 4, 5]
b. [0, 1, 2, 3, 4]
c. [-4, -2, 0, 2, 4]
d. (0, 1, 4,9, 16]
399, What will be the output after the following statements?
x = [i**2-3 for i in range(0,7,3)]
print(x)400. What will be the output after the following statements?
x = [i**4//7 for i in range(o,6,2)]
print(x)
401. What will be the output after the following statements?
x = [int(i**3/3) for i in range(0,5,2)]
print(x)
a. [0, 2, 36]
b.[0, 2, 21]
c. [0, 6, 2]
d. (0, 2, 14]
402, What will be the output after the following statements?
x = [int(i/2-5) for i in range(3,8,2)]
print (x)
a. [-3, -2, -1]403. What is the famous one-line Hello World program of Python?
a. print("Hello World!")
b. print "Hello World!"
c, print("Hello World!")!
d. print("Hello Worl
404. What is used for multi-line strings in Python?
a. Three braces {{{ yy
b. Three Colons
c. Three hashes #### ‘tt
d. Three Quotes "™
4
&
. What will be the output after the following statements?
x = 90
= 'I ran for %s minutes’
print(y % x)
a. y ran for x minutes
b. y ran for 90 minutes
c. Iran for 90 minutes
d. Tran for x minutes
4
&
6. What will be the output after the following statements?
Nw x
wun
"she!
60
‘ran for %s minutes’print(x, z % y)
a. ran for 60 minutes
b. she ran for 60 minutes
c, She ran for 60 minutes
d. x ran for 60 minutes
407, What will be the output after the following statements?
7S
60
‘ran for %s minutes'
print(z % y)
a. ran for 75 minutes
b. ran for 60 minutes
c. ran for 135 minutes
d.y ran for 60 minutes
408, What will be the output after the following statements?
"He ran for %s minutes for %s days'
rint(z % (x, y))
UNKX
a. He ran for 7 minutes for 7 days
b. He ran for 6 minutes for 6 days
c. He ran for 6 minutes for 7 days
d. He ran for 7 minutes for 6 days
409. What will be the output after the following statements?x = 'Python 2!
y = "Python 3!
z = 'We can convert %s program to %s program’
print(z % (x, y))
a. We can not convert Python 2 program to Python 3 program
b. We can not convert Python 3 program to Python 2 program
c. We can convert Python 2 program to Python 3 program
d. We can convert Python 3 program to Python 2 program
410. What will be the output after the following statements?
Ket!
print(x*5)
a. Displays a tab
b. Displays 5 spaces
c. Displays a newline
d. Displays 10 quotes
411. What will be the output after the following statements?
print(a)
a. 'yes’, ‘may be’, ‘no!
b. ‘no’, ‘may be’, 'yes'
c. ['no’, ‘may be’, 'yes']
. ['yes', ‘may be’, ‘no']412, Which of the following operations is not possible while manipulating lists?
a. Addition
b. Multiplication
c. Division
d. Deletion
413, Which of the following is used by interpreter to identify code blocks?
a. Braces
b. Indentation
c. Commas
d. Expressions
414, What will be the output after the following statements?
x = ["Yesterday's", "Today's", "Tomorrow's"]
y = ['weather', ‘temperature’, ‘humidity']
for i in
print(i, end=' ')
for j in y:
print(j, end=
‘)
a. Yesterday's Today's Tomorrow's weather temperature humidity
b. Yesterday's weather temperature humidity
c. Yesterday's weather temperature humidity Today's Tomorrow's
d. Yesterday's weather Today's temperature Tomorrow's humidity
415. What will be the output after the following statements?
x = ["Yesterday's", "Today's", "Tomorrow's"]
y = ['temperature']
for i in x:
print(i, end=" ')
for j in yprint(j, end=' ')
a. Yesterday's Today's Tomorrow's temperature
b. Yesterday's temperature
c. Yesterday's temperature Today's Tomorrow's
d. Yesterday's temperature Today's temperature Tomorrow's temperature
416, What will be the output after the following statements?
x = ["Yesterday's", "Today's", "Tomorrow's"
y = ['temperature']
for i in x:
if ife] == 'T
for j in y:
print(i, j, en
a. Today's Tomorrow's temperature
b. Today's temperature Tomorrow's temperature
c. temperature Today's Tomorrow's
d. Today's temperature Tomorrow's
417. What will be the output after the following statements?
x = ["Yesterday's", "Today's", "Tomorrow's"]
y = ['temperature']
for iin x:
if ifo] i="
for j in y:
print(i, eni
y
a. Today's Tomorrow's temperature
b. Yesterday's temperature Tomorrow's temperature
c. Yesterday's
d. Yesterday's Today's Tomorrow's418. What will be the output after the following statements?
x = ["Yesterday's", "Today's", "Tomorrow's"]
y = ['temperature']
for i in x:
if ifo] '= ty":
for j in y:
print(j, end=" ')
a, temperature temperature
b. temperature
c. temperature temperature temperature
d. Yesterday's Today's Tomorrow's
419. What will be the output after the following statements?
x 25
y = 10
while x < 26 and y < 11
x=xed
y=ye+a
print(x,y)
a. 26 11
b. 2511
c. 25 10
d. 26 10
420. What will be the output after the following statements?
x = 25
y = 10
while x < 26 and y < 11
print(x,y)
xexela. 26 11
b. 2511
c. 25 10
d. 26 10
421, What will be the output after the following statement?
print(list(range(@,5)))
a. list(range(0,5))
b. list(0, 1, 2, 3, 4)
c.0,1,2,3,4
a. [0, 1, 2, 3, 4]
422. What will be the output after the following statements?
def abc(world)
print('hello %s' % world)
abe('Python')
a. hello world
b. hello Python
c. hello
d. hello % world
423, What will be the output after the following statements?
def abe(x, y):
print(‘hello %s %s' % (y, x))
abe('Python', 'world')a. hello world
b. hello Python world
c. hello Python
d. hello world Python
424. What will be the output after the following statements?
b
a
de
*python'
"world"
pypi(x, y):
print(‘hello %s %s' % (y, x))
Pypi(a, b)
Suu
a. hello world
b. hello Python world
c. hello Python
d. hello world Python
425. What will be the output after the following statements?
= 12
= 45
= 10
f pypi(x, y, 2):
return(z * y - x)
print(pypi(b, c, a))
a
b
c
de
aa
SAS
poge426, What will be the output after the following statements?
def pypi():
b = 25
c= 20
return(a * b - c)
a=12
print(pypi())
a. 280
b. Error
c. 60
d. 215
427, What will be the output after the following statements?
class Furniture:
def legs(x):
print(‘has Xs legs! % x)
Furniture. legs(4)
a. Furniture has 4 legs
b. Error
c. has 4 legs
d. legs has 4 legs
428. What will be the output after the following statements?
class Furniture:
def legs()
print('is made of wood")
Furniture. legs()
a, Furniture is made of woodb. is made of wood
c. print(is made of wood)
d. legs is made of wood
429, What will be the output after the following statements?
class Furnitur
def chair(x):
print('It has %s legs' % x)
def table(x):
print('It has %s legs’ % x)
Furniture. table(6)
a. It has 4 legs
b. It has no legs
c. Ithas 0 legs
d. It has 6 legs
430, What will be the output after the following statements?
class Furnitur
def chair():
print('It has 4 legs')
def table():
print('It has 6 legs‘)
Furniture.chair()
a. It has 4 legs
b. It has no legs
c. It has 0 legs
d. Ithas 6 legs
431. What will be the output after the following statements?x= -4
if abs(x) > 0:
print('This is absolute value')
a. None
b. Error
c. Wrong Value
d. This is absolute value
432. What will be the output after the following statements?
x= -3
if abs(x) < 3:
print(x)
else:
print(@)
a. No output
b. Error
c.0
d. -3
433. What will be the output after the following statements?
x= -4
if bool(x):
print(x)
else:
print(0)
a. No output
b. Error
c.0
d.-4434. What will be the output after the following statements?
x=0
if bool(x):
print(x)
else:
print(5)
a. No output
b. Error
a5
d.0
435. What will be the output after the following statements?
x = ‘None!
if bool(x):
print('Yes')
else:
print('No')
a, None
b. Yes
c. No
d.0
436. What will be the output after the following statements?
xe!
if bool(x):
print('Yes')
else:
print('No')a. None
b. Yes
c. No
d.0
437. What will be the output after the following statements?
Kero
if bool(x):
print('Yes')
else:
print('No')
a, None
b. Yes
c. No
d.0
438. What will be the output after the following statements?
x= []
if bool(x):
print('Yes')
else:
print('No')
a. No
b. Yes
c. None
do
439. What will be the output after the following statements?x= [1, 2, 3]
if bool(x):
print('Yes')
else:
print('No')
a. No
b. Yes
c. None
do
440. What will be the output after the following statements?
x='
if not bool(x)
print('Yes')
else:
print('No")
a. Yes
b. No
c, None
do
441, What will be the output after the following statements?
x = 'print("Python")'
eval (x)
ax
b. print("Python")
c. Python
do442, What will be the output after the following statements if input entered is
45*2?
x = input("Enter an expression: ")
print (eval(x))
a, 45*2
b. eval("90")
c. 90
d.0
443. What will be the output after the following statements?
x = '''print("Python 3", end="')
print(" is Good")'''
exec(x)
a. Python 3is Good
b. Python 3 is Good
c. Python 3
d. is Good
444. What will be the output after the following statements?
a=['a', 'b', 'c', 'A', 'B']
print (max(a))
pBoeoe
acpe445, What will be the output after the following statements?
a=['a', 'b', 'c', 'A', 'B'
print (min(a))
Boge
oop
446, What will be the output after the following statements?
a=['a', 'b', ‘et, '1', 12", ‘AY, 1B]
print (max(a))
Boe
ae pe
447. What will be the output after the following statements?
a=['a', 'b', ‘et, '1', 12", ‘AY, 1B]
print (min(a))
Boge
ae pe
448. What will be the output after the following statements?a= [4, 2, 3]
print (sum(a))
poe
a-Nw
449, What will be the output after the following statements?
a = list(range(0, 19, 3))
print(sum(a))
a. 10
b. 100
c. 18
d. 30
450. What will be the output after the following statements?
a = list(range(19, -10,3))
print (sum(a))
a. 10
b.0
c. 18
d. 90
451, What will be the output after the following statements?
a = list(range(-10,5,2))print(sum(a))
a. -24
b.0
c, 24
d. 20
b
&
2. What will be the output after the following statements?
x= [5, 4, 3, 2, 1]
y = x.copy()
x[o] = 6
print(y)
a. [6, 4, 3, 2, 1]
b.6
c. (5, 4,3,2, 1]
a5
453, What will be the output after the following statements?
import copy
x = (5, 4, 3, 2, 1]
y = copy. copy(x)
x.append(6)
print(y[0])
[6, 4, 3, 2, 1]
6
[5, 4, 3, 2, 1]
a.
b.
c
dis
454. What will be the output after the following statements?import keyword
print (keyword. iskeyword('IS'))
a. True
b. keyword
c. for
d. False
455, What will be the output after the following statements?
import keyword
print (keyword, iskeyword('for'))
a. True
b. keyword
c. for
d. False
456, What will be the output after the following statements?
import keyword
print(keyword,iskeyword('Python'))
a. True
b. keyword
c. for
d. False
457, What will be the output after the following statements?import random
x = [3, 8 6, 5, 0]
print(random.choice(x))
a. A random element from the list x
b. The list x
c. Arandom element from the list x, excluding 3 and 0
d. A random element from the list elements 3 and 0
458. What will be the output after the following statements?
import random
x= [3, 8, 6, 5, 0]
random. shuffle(x)
print (x)
a. A random element from the list x
b. The shuffled list x with the elements mixed up
c. A random element from the list x, excluding 3 and 0
d. A random element from the list elements 3 and 0
459. What will be the output after the following statements?
import random
x = [3, 8, 6, 5, 0]
y = random. shuffle(x)
print(y)
a. A random element from the list x
b. The shuffled list x with the elements mixed up
c. None
d. A random element from the list x, excluding 3 and 0460. What will be the output after the following statements?
import sys
X = sys.stdout write('Python Jobs")
a. A random character from the string ‘Python Jobs’
b. Python Jobs
c. None
4. Py
461. What will be the output after the following statements?
import time
print(time.time())
a. Current time in seconds since the Epoch at 00:00:00 GMT on January 1, 1970
b. Today's time in hours
c. None
d. Today's time in minutes
462. What will be the data type of the output after the following statements?
import time
print (time.time())
a. String
b. Integer
c. List
d. Float
463. What will be the data type of the output after the following statements?import time
print(time.asctime())
a. String
b. Integer
c. List
d. Float
464. What will be the output after the following statements?
import time
print(time.asctime())
a. Current time in seconds since the Epoch at 00:00:00 GMT on January 1, 1970
b. Current date and time
c. None
d. Today's time in minutes
465. What will be the output after the following statements?
import time
y = (2016, 2, 10, 12, 45, 32, 5, 0, @)
print (time.asctime(y))
a. Current time in seconds since the Epoch at 00:00:00 GMT on January 1, 1970
b. Current date and time
c. Sat Feb 10 12:45:32 2016
d. No output
466. What is likely to be the output after the following statements?import time
y = time,asctime()
print(y[:3])
a. 2016,
b. 3:40
c. Mon
d. 04
467. What will be the output after the following statements?
import random
print (int (random. random()*10) )
a. 10
b. A random integer number within the range of 0 to 9
c. None
d. A random floating point number within the range of 0 to 9
468. What will be the output after the following statements?
import random
print(int(random.random()*19) + 1)
all
b. A random integer number within the range of 0 to 11
c. None
d. A random whole number within the range of 1 to 10
469. What will be the output after the following statements?
import randomprint(random,sample(range(20), 5))
a. A list of 5 unique numbers within the range of 0 to 19
b. A list of 5 unique numbers within the range of 0 to 20
c. A list of 4 unique numbers within the range of 0 to 19
d. A tuple of 5 unique numbers within the range of 0 to 19
470, What will be the output after the following statements?
import random
print(random.sample(range(5, 20), 4))
a. A list of 5 unique numbers within the range of 4 to 19
b. A list of 5 unique numbers within the range of 5 to 20
c. A list of 4 unique numbers within the range of 5 to 19
d. A tuple of 4 unique numbers within the range of 5 to 19
471, What will be the output after the following statement?
print(a)
a. SyntaxError
b. TypeError
c. ValueError
d. NameError
472. What will be the output after the following statement?
a = "Python Practice!a. SyntaxError
b. TypeError
c. ValueError
d. NameError
473. What will be the output after the following statement?
a = true
a. No Error
b. TypeError
c. ValueError
d. NameError
474. What is the value of the NoneType data type?
a, undefined
b. Null
c. Nan
d. None
475. What will be the output after the following statements?
def xyz():
a= 56
xyz()
print(a)
a. NameError
b. 56
ca=56
d. xyz476, What will be the output after the following statements?
a, NameError
b. 40
c. 10
d. 32
477. What will be the output after the following statements?
def xyz():
x = 40
def abc():
xyz()
a= 32
x = 10
print(x)
abe()
a. NameError
b. 40
c. 10
d. 32
478, What will be the output after the following statements?
def abc():
print(x)x= 10
abe()
. NameError
x
479, What will be the output after the following statements?
def abc():
x = 12
print (x)
x = 10
abe()
a, NameError
b. 12
c. 10
d.0
480. What will be the output after the following statements?
def abc():
x = 10
print (x)
abe()
x= 12
a. NameError
b. 12
c. 10
do48
. What will be the output after the following statements?
def abc():
global x
x = 23
x = 10
abe()
print (x)
a. NameError
b. 23
c. 10
d.0
482, What will be the output after the following statements?
def abc():
print (x)
x = 10
abe()
x = 20
a. NameError
b. 20
c. 10
d. UnboundLocalError
483. What will be the output after the following statements?
def abc(x):
return 20 / x
print (abc(4))
a. NameErrorb.5
c.5.0
d. ZeroDivisionError
484, What will be the output after the following statements?
def abe(x):
return 20 / x
print (abe(®))
a. NameError
b. Undefined
c.5.0
d. ZeroDivisionError
485. What will be the output after the following statements?
def abc(x
try:
print(20 / x)
excep’
print('Not a valid argument', end=" ')
print(abc(@))
a. NameError
b. Not a valid argument
c. Not a valid argument None
d. ZeroDivisionError
486, What will be the output after the following statements?
def abc(x):
try:
print(20 / x)except:
print('Not a valid argument', end=" ')
finally
print(o, end=' ')
print(abc(0))
a. Not a valid argument 0 None
b. Nota valid argument
c. Not a valid argument None
d. ZeroDivisionError
487. What will be the output after the following statements?
x= [1, 2, 3, 4]
print(x[4])
a4
b.3
c. 1, 2, 3, 4]
dt
IndexError
488. What will be the output after the following statements?
x = [10, 20, 30, 40]
print (x[20])
a, 20
b. 30
c. [20]
d. IndexError
489. What will be the output after the following statements?x = [1.0, 2.0, 3.0]
print (x[2.0])
a.2
b.3.0
c. TypeError
d. IndexError
490, What will be the output after the following statements?
x = [1.0, 2.0, 3.0]
print (x[int(2.0)])
a.2
b.3.0
c. TypeError
d. IndexError
491, What will be the output after the following statements?
x = ['Today', ‘nice’, 'day']
print(x[0] + ' is a ' + x[4] + x[2])
a. Today is a niceday
b. Today is a nice day
c. Todayis aniceday
d. Todayisaniceday
492, What will be the output after the following statements?
x = ['Today', ‘Sunday’, 'Monday"]print(x[@] + ' was a great day')
a. Today was a great day
b. Sunday was a great day
c. TypeError
d. IndexError
493, What will be the output after the following statements?
x = ['Today', ‘Sunday’, 'Monday']
print(x[-1] + ' was a great day')
a. Today was a great day
b. Sunday was a great day
c. Monday was a great day
d, IndexError
494, What will be the output after the following statements?
x = ['Today', ‘Sunday’, 'Monday']
print(x[-3] + ' was a great day')
a. Today was a great day
b. Sunday was a great day
c. Monday was a great day
d. IndexError
495, What will be the output after the following statements?
x = ['Today', ‘Sunday’, ‘Monday']
x[2] = 'Friday'
x[1] = 'Yesterday'print(x[-2] + ' was a great day")
a. Friday was a great day
b. Sunday was a great day
c. Monday was a great day
d. Yesterday was a great day
496, What will be the output after the following statements?
x = ['Today', 'Sunday', 'Monday']
y = [4, 6, 8]
print(y + x)
a. [Today’, ‘Sunday’, "Monday’, 4, 6, 8]
b. [4, 6, 8, ‘Today’, ‘Sunday’, ‘Monday']
c. [Today’, 'Sunday', 'Monday’]
d. 4, 6, 8]
497. What will be the output after the following statements?
x = "Monday!
print(’Mon' in x)
a. ‘Mon’ in x
b. ‘Monday’ in x
c. True
d. False
498. What will be the output after the following statements?
x = 'Monday’
print('Day’ not in x)a. 'Day' not in x
b. ‘Monday’ not in x
c. True
d. False
499. What will be the output after the following statements?
x = ['hot', '100', True]
weather = x[0]
temperature = x[1]
humid = x[2]
print(weather, temperature, humid)
ax
b. [‘hot’, '100', True]
c. ‘hot’, '100', True
d, hot 100 True
500. What will be the output after the following statements?
x = ['hot', '100', True]
weather, temperature, humid = x
print(weather, temperature, humid)
a. ValueError
b. [‘hot’, '100', True]
c. ‘hot’, '100', True
d. hot 100 True
501. What will be the output after the following statements?x = ['hot', '100', True]
weather, humid = x
print(weather, humid)
a. ValueError
b. hot 100
c. hot True
d, hot 100 True
502. What will be the output after the following statements?
x = ['hot', '100', True]
x. remove('100')
weather, humid = x
print(weather, humid)
a. ValueError
b. hot 100
c. hot True
d. hot 100 True
503. What will be the output after the following statements?
x= [la’, 'bY, tet, (At, 'Bt, tee]
x.sort()
print(x)
a. SortError
b. ['a', bY, ‘cA’, "BY 'C']
c. ['a’, ‘A’, 'b’, 'BY, 'c’, 'C']
4. ['A’, 'B', 'C;, ‘a’, ‘bY, 'c']
504. What will be the output after the following statements?x= [lat, ‘bt, ‘eh, TA, BY 164
x.sort (key=str, lower)
print(x)
a. SortError
b. ['a’, 'b’, 'c, ‘A’, ‘BY, 'C']
c.['a''A, v By 'C]
d.['A’, BY 'C’,'a', bi, 'c']
505. What will be the output after the following statements?
= [lat, "bY, 'e, tAY, 'BY, 4]
x.sort(key=str, swapcase)
print(x)
a. TypeError
b.['a','bi,'c',"A’, BY, 'C"
c.['a', ‘AY, 'D','BI,'c,
4. [As BY, "Ca, b5,'c]
506. What will be the output after the following statements?
= [la', 'b', 4, 2, "AY, "BY
x.sort()
print(x)
a. TypeError
b. [aby 'c, "A, BY, a
c.Ea','AY, by, BY 'c
a. [A\ B,C ‘eb vel507. What will be the output after the following statements?
import random
x = ['Monday', 'Tuesday', ‘Wednesday’, ‘Thursday’, 'Friday',
‘saturday’, 'Sunday']
print (x[random.randint(@, len(x) - 1)])
a. IndexError
b. A random day from all the seven days
c. A random day from all the days except Sunday
d. A random day from all the days except Monday
508, What will be the output after the following statements?
x = 'Today is a nice day' + \
' Twill go for a walk today’
print(x)
a. SyntaxError
b. Today is a nice day
c. Iwill go for a walk today
d. Today is a nice day I will go for a walk today
509. What will be the output after the following statements?
x = ‘Today is a nice day’
x[9] = ‘not '
print (x)
a. TypeError
b. Today is a nice day
c. SyntaxError
d. Today is not a nice day510. What will be the output after the following statements?
x = "Today is a nice day*
y = x[:9] + ‘not ' + x[9:]
print(y)
a. TypeError
b. Today is a nice day
c. SyntaxError
d. Today is not a nice day
511. What will be the output after the following statements?
x = 'Today is a nice day'
y= x[:9] + ‘not ' + x[9:]
print (x)
a. TypeError
b. Today is a nice day
c. SyntaxError
d. Today is not a nice day
512. What will be the output after the following statements?
x = ‘Today is not a nice day’
x = ‘Today is a nice day’
print(x)
a. TypeError
b. Today is a nice day
c. SyntaxErrord. Today is not a nice day
513. What will be the output after the following statements?
x = ('Today', ‘nice’, ‘day’)
x[4] = 'not!
print(x)
a. TypeError
b. (Today’, ‘nice’, ‘day’)
c. SyntaxError
d. (‘Today’, ‘not, ‘nice’, 'day')
514. What will be the data type of the output after the following statements?
x = ('Today')
print(x)
a. TypeError
b. String
c. Tuple
d. List
515. What will be the data type of the output after the following statements?
x = ('Today',)
print(x)
a. TypeError
b. String
c. Tuple
d. List516. What will be the data type of y after the following statements?
[1, 2, 3, 4]
tuple(x)
x
wu
. TypeError
b. String
c. Tuple
d. List
517. What will be the data type of z after the following statements?
x= [1, 2, 3, 4]
= tuple(x)
= list(y)
n<
a. TypeError
b. String
c. Tuple
d. List
518. What will be the data type of the output after the following statements?
x = 'python'
y = list(x)
print(y)
a. TypeError
b. String
c. Tuple
d. List519. What will be the data type of the output after the following statements?
x = 'Python'
y = tuple(x)
print(y)
a. TypeError
b. String
c. Tuple
d. List
520. What will be the output after the following statements?
x = (‘Python')
print(x)
a.(P','y,,'t, ‘hy, '0','n)
b. Python
c. Python
d. (‘Python’)
521. What will be the output after the following statements?
x = (‘Python', )
print(x)
a. (‘Python’)
b. Python
c. Python
d. (‘Python’)522. What will be the output after the following statements?
x= [0, 2, 4, 6]
print (tuple(x))
523. What will be the output after the following statements?
x= (0, 2, 4, 6)
print(list(x))
524, What will be the output after the following statements?
x = ‘Python’
print(list(x))
a. (Py, 't, ‘hy, 'o',‘n')
b. (Python)
c. ED 'y, "th, 0, 'n']
4. [Python’]
525. What will be the output after the following statements?x = 'Python'
print(tuple(x))
a. (P,'y',"t, ‘hy, 'o','n')
b. (Python)
cP 'y','t, ‘hy, 'o', ‘n']
. ['Python']
526, What will be the output after the following statements?
[4, 5, 7, 8, 9]
x
y
y{4] =6
print(y)
527. What will be the output after the following statements?
[4, 5, 7, 8, 9]
x
y
y{4] = 6
print(x)528. What will be the output after the following statements?
def abc(z):
z.append(44)
x= [7, 8, 9]
abe(x)
print (x)
529. What will be the output after the following statements?
import copy
x = (5, 4, 3, 2, 1]
y = copy.copy(x)
x.append(6)
print(y[-1])
a5
b.6
c. [5, 4, 3, 2, 1, 6]
di
530. What will be the output after the following statements?
import copy
x= [5, 4, 3, 2, 1]
y = copy. copy(x)
x[2] = 6
print(y[2]). 3
. 6
15, 4, 6, 3, 2, 1]
4
apogee
531. What will be the output after the following statements?
import copy
x= (5, 4, 3, 2, 1]
(7, 8, 9]
z= y]
a = copy.copy(z)
x[2] = 6
print (a)
532, What will be the output after the following statements?
import copy
x = [5, 4, 3, 2, 1]
a = copy. deepcopy(z)
x[2] = 6
print(a)533. What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print(x['year'])
a. day
b. KeyError
c. Sunday
d.10
534, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
for i in x.values():
print(i, end=" ')
a. Sunday 10
b. KeyError
c. Sunday
d.10
535. What will be the output after the following statements?
x = {'day':'Sunday’, 'week':10}
for i in x:
print(i, end=" ')
a. Sunday 10
b. day week
c. Sunday
d.10536. What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
for i in x.keys()
print(i, end=" ')
a. Sunday 10
b. day week
c. Sunday
d.10
537. What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
for i in x.items():
print(i, end=' ')
a. (‘day’, Sunday’) (‘week’, 10)
b. day week
c. (‘week’, 10)
. (‘day’, 'Sunday’)
538, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print (list (x.keys()))
a. Sunday 10
b. day week
c. ['day’, 'week']
d. (day, week)539, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print (tuple(x.items()))
a. (week’, 10), (‘day’, '‘Sunday’))
b. (‘day’, 'Sunday’) (‘week’, 10)
c. ['day’, 'week']
d. (day, week)
540, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print (tuple(x.values()))
a. Sunday 10
b. (‘Sunday’, 10)
c. ['Sunday’, 10]
d.10
541. What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
for i, j in x.items()
print(i, j, end=" ')
a. (‘day’, ‘Sunday’) ‘week’, 10)
b. {'day':'Sunday’, ‘week':10}
c. 'day’'Sunday’, 'week':10
d. day Sunday week 10
542. What will be the output after the following statements?x = {'day':'Sunday', ‘week! :10}
print('day' in x.values())
a. Sunday
b. True
c. False
d. day
543, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print('day' in x.keys())
a. Sunday
b. True
c. False
d. day
544, What will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print(x.get('day', 'Friday'))
a. Friday
b. True
c. Sunday
d. day
545, What will be the output after the following statements?