Parvez Ahmed - The Ultimate Python Quiz Book - 2024
.pdfVariables and Keywords - 01 |
250 Python Quizzes |
05. What is the output of the following code?
p = q
q = 'hello' print(p)
A)hello
B)q
C)Blank Output
D)Error
06. Which of the following is not a keyword in Python?
A)except
B)final
C)from
D)global
07. What is the output of the following code?
r = 5 + 8 print('r')
A)5 + 8
B)r
C)13
D)Error
08. How many keywords (as of Python 3.11) are not completely lowercase?
A)2
B)5
C)3
D)4
010
Variables and Keywords - 01 |
250 Python Quizzes |
09. An __________ is a unique user-defn ed name assigned to a variable, function, or class.
A)Iterator
B)Identifier
C)Literal
D)Operator
10. What must be the input given to m in order to get 8 as the output?
m = int(input()) n = m * 3
p = n - 4 q = p + m print(q)
A)3
B)5
C)8
D)0
011
Variables and Keywords - 02 |
250 Python Quizzes |
Variables and Keywords - 02
01. Which of the following keywords is not used as an operator?
A)is
B)in
C)or
D)as
02. What is the syntax to assign the number 76 to variables r, s, and t using a single line?
A)r + s + t = 76
B)r = s = t = 76
C)r, s, t = 76
D)r, s, t = 76 * 3
03. What is the output of the following code?
x, y, z = 'y', 'z', 'x' print(z, 'x', y)
A)y z x
B)x y z
C)x x z
D)y x z
04. Which of the following is a keyword in Python?
A)default
B)del
C)false
D)local
012
Variables and Keywords - 02 |
250 Python Quizzes |
05. What is the output of the following code?
a, b, c = 3, 8, 5 d = b - c
b = d + a a = b - c
print(d, a, b, c)
A)1 6 5 3
B)3 1 6 5
C)3 3 8 5
D)3 1 8 5
06. On executing the following code, how many objects has Python created?
val = 'code' var = val
A)0
B)3
C)2
D)1
07. On executing the following code, how many references has Python created?
val = 758 var = val
A)2
B)0
C)3
D)1
013
Variables and Keywords - 02 |
250 Python Quizzes |
08. What is the output of the following code?
c = 'choco' d = 'bar' c, d = d, c print(c, d)
A)bar choco
B)choco choco
C)bar bar
D)choco bar
09. What is the output of the following code?
g = 'goat' print(*g)
A)g o a t
B)g
C)goat
D)Error
10. Which of the following is a soft keyword as of Python 3.11?
A)break
B)pass
C)case
D)async
014
Data Types - 01 |
250 Python Quizzes |
Data Types - 01
01. How is the dictionary data type represented in Python?
A)dict
B)dictionary
C)dic
D)dicts
02. Which of the following values is not a tuple?
A)('A')
B)10, 20
C)([10], [20])
D)(10,)
03. Which of the following values displays an error if printed?
A){10, 20, 10}
B){1: 10, 2: 20, 1: 30}
C){6, [2, 3], 5}
D)[1, ['Hello'], 1]
04. What is the output of the following code?
a = 00 print(list(str(a))
A)['00']
B)['0']
C)['0', '0']
D)Error
015
Data Types - 01 |
250 Python Quizzes |
05. What is the output of the following code?
d = {1: 'A', 2: 'B', 1: 'C'} print(d)
A){1: 'A', 2: 'B'}
B){1: 'A', 2: 'B', 1: 'C'}
C){1: 'C', 2: 'B'}
D)Error
06. What is the output of the following code?
data = '20.0', Print(type(data))
A)<class 'int'>
B)<class 'float'>
C)<class 'str'>
D)<class 'tuple'>
07. Which of the following is a scientifc notation of 0.095 in Python?
A)9.5e-3
B)9.5e3
C)95e-2
D)0.95e-1
08. Which of the following is an example of an implicit type conversion?
A)String to List
B)Integer to Float
C)Tuple to List
D)Float to Integer
016
Data Types - 01 |
250 Python Quizzes |
09. What is the output of the following code?
r = 3 s = 5
print(str(s + r))
A)35
B)8
C)53
D)Error
10. What is the output of the following code?
print(isinstance('true', bool))
A)True
B)False
C)true
D)Error
017
Data Types - 02 |
250 Python Quizzes |
Data Types - 02
01. Which of the following is a mutable data type in Python?
A)Integer
B)Dictionary
C)Complex
D)String
02. Which of the following represents an empty set in Python?
A)[]
B)set()
C){}
D)()
03. What is the output of the following code?
a = '01.01' print(int(a))
A)01
B)1
C)1.01
D)Error
04. Which of the following data type conversion is not possible in Python?
A)String to Integer
B)List to Tuple
C)List to Integer
D)Complex to String
018
Data Types - 02 |
250 Python Quizzes |
05. What is the output of the following code?
num = 6 print(complex(num))
A)6.0
B)6j
C)6+0j
D)Error
06. What is the output of the following code?
s = '123' print(list(s))
A)[1, 2, 3]
B)[123]
C)['1', '2', '3']
D)['123']
07. What is the output of the following code?
var = '100' print(int(var, 2))
A)100
B)2
C)4
D)Error
019