Test Your Knowledge of Python Operators - Quiz
Take this Python Operators Quiz to test your understanding of arithmetic, comparison, logical, and assignment operators in Python. The questions test both practical and conceptual knowledge of Python operators.
Question 1.
What is the output of the following code?
print( 2 ** 3 ** 2 )
Question 2.
What is the output of the following code?
print( 10 // 3 )
Question 3.
Which of the following is not a valid comparison operator?
Question 4.
What does the following comparison operation evaluate to?
3 == 3.0 == 3 + 0j
Question 5.
What does the following logical operation evaluate to?
not (True and False)
Question 6.
Which operator has a higher precedence, and
or or
?
Question 7.
What is the result of the following expression?
not 0 and 5
Question 8.
What is the output of the following code?
x = 5
x *= 2 + 3
print( x )
Question 9.
What does the in
operator check for in a dictionary?
Question 10.
What does the is
operator check?
Question 11.
What is the output of the following code?
print( [1, 2] is [1, 2] )
Question 12.
Which of the following expressions will raise an error?
Question 13.
What does the following expression evaluate to?
"apple" > "banana"
Question 14.
Which operator is used to perform bitwise OR.?
Question 15.
What is the result of the following expression?
5 << 2
Question 16.
What is the output of the following code?
x = (a := (b := 5)) + b
print( x )
print( a )
print( b )
Question 17.
What is the output of the following code
x = [1, 2]
y = x
y.append( 3 )
print( x )
Question 18.
Which of the following special method is used to overload the +
operator in a custom class?
Question 19.
What is the difference between in
and is
in Python?
Question 20.
If a custom class defines __eq__()
but not __ne__()
, what happens when the !=
operator is used with objects of that class?