Python Mcqs
Python Mcqs
a)34
b)42
c)24
d)1
___________________________________________________________
2)
a)2
b)2.0
c)0
d)1
_____________________________________________________________
3)
a)geeksforgeeks
b)GEEKSFORGEEKS
_____________________________________________________________
4)
a)1
b)2
c)3
4)4
_____________________________________________________________
5)
a)2
b)3
c)4
d)1
6)
a)555
b)111
c)None of the above
d)1
7)
a)0 1 2 5
b)0\n 1\n2\n4\n5\n
c)0\n 1\n4\n5\n
d)0 1 4 5
8)
a)True\nTrue\nTrue\nTrue
b)1\n2\n3\n4\n
c)1 2 3 4
d){True,True,True,True}
9)
a)3
b)2
c)0
d)4
_____________________________________________________________
10)
a)491
b)149
c)51
d)50
11)
a)GeeksforGeeks13
b)ASCII(GeeksforGeeks)+b
c) Error
d)(GeeksforGeeks)print for 13 times
12)
a)1
b)2
c)3
d)4
13)
a)1
b)3
c)2
d)4
14)
a)Error
b)k
c)h
d)Pratik
15)
a)Error
b)Exception
c)-5
d)5
16)
a)4
b)5
c)8
d)7
17)
a)5
b)4
c)1
d)6
18)
a)Error
b)cool
c) is
d)1
19)
a) 111\n 121\n231
b) 111\n121\n323
c) 111\n323\n333
d) D)111\n 333\n221
20)
a)2
b)12
c)10
d)4
21
b)Error
c) [0, 1]
[3, 2, 1, 0, 1, 4]
[0, 1, 0, 1, 4]
d) [0,1,2,3,4,5]
[3,2,1]
[0,1,0,1,4]
22)
___________________________________________________________________
23)
___________________________________________________________________
24)
___________________________________________________________________
25)
26)
27)
28)
29)
30)
31)
Answer:____________
32)
Ans:________
33)
Ans:___________
___________________________________________________________________
34)What is the Output?
Ans:____________
___________________________________________________________________
35)
Ans:
36)
37)
38)
___________________________________________________________________
39)
40)
41)
42)
43)
nums = [1, 2, 3, 4]
squared = [x ** 2 for x in nums]
print(squared)
a) [1, 4, 9, 16]
b) [1, 2, 3, 4]
c) [2, 4, 6, 8]
d) [1, 8, 27, 64]
45)
x = 10
def foo():
global x
x += 5
foo()
print(x)
a) 10
b) 15
c) 5
d) 20
46) Which of the following is true about Python's Global Interpreter Lock (GIL)?
a) It allows only one thread to execute Python bytecode at a time in a single process.
47)
48)
49)
49)
a) [’11’, ‘4’, ‘1886’, ’11’] b) [‘1141886’] [‘1’, ‘1’] c) [’11’, ‘4’, ‘1886’] [’11’] d)
[’11’, ‘4’, ‘1886’] [‘1’, ‘1’]
50)
51)
52)
53)
54)
55)
56)
57)
58)
59)
60)
61)
62)
63)
64)
65)
66)
a)Mutable
b)Immutable
c)data structure
d)both a&c
a)Mutable
b)Immutable
c)Cannot be determined
69)
70)
71)
72)
73)
74)
75) As what datatype are the *args stored, when passed into a function?
76)
77)
78) Which of the following blocks will always be executed whether an
exception is encountered or not in a program?
79)
83)
84) Which of the following are valid escape sequences in Python?
86) Which of the following modules need to be imported to handle date time
computations in Python?
87) How can assertions be disabled in Python?
88)
91)
92)
93)
94)
95)
96)
97)
98)
99)
100)
Answers:
1)c 2)b 3)b 4)c 5)c 6)b 7)c 8)b 9)a 10)c 11)c 12)d
13)c 14)b 15)b 16)b 17)a 18)b 19)b 20)b 21)c 22)c 23)d 24)b
25)b 26)a 27)d 28)c 29)d 30)c 36)1 37)3 38)3 39)d 40)a 41) b
42)b 43)a 44)d 45)b 46)a 47)b 48)a 49)b 49)d 50)b 51)d 52)a
53)a 54)b 55)c 56)d 57)4 58)1 59)2 60)4 61)2 62)4 63)4 64)3
65)1 66)3 67)d 68)a 69)b 70)a 71)a 72)a 73)a 74)c 75)b 76)a
77)c 78)c 79)d 80)a 81)b 82)d 83)a 84)d 85)d 86)a 87)a 88)a
89)b 90)b 91)b 92)a 93)a 94)a 95)a 96)a 97)b 98)d 99)a
100)a