Welcome to our Python Operators and Expressions quiz! Understanding operators and expressions is essential in Python programming as they kind the inspiration for manipulating knowledge and controlling program circulate. This quiz will check your information of varied sorts of operators resembling arithmetic, comparability, and logical operators, in addition to how expressions are evaluated in Python. Get able to problem your self and deepen your understanding of those elementary ideas!

30+ MCQs on Python Operators and Expressions
Q1. Which operator is used to calculate the rest of a division?
a) %
b) //
c) /
d) **
Reply: a
Rationalization: The % operator in Python is used to calculate the rest of a division operation. For instance, 10 % 3 ends in 1 as a result of 10 divided by 3 equals 3 with a the rest of 1.
Q2. What’s the results of the expression 4 < 5 and 5 < 6?
a) True
b) False
c) Error
d) Not one of the above
Reply: a
Rationalization: The expression 4 < 5 and 5 < 6 evaluates to True as a result of each situations are true. In Python, the and operator returns True provided that each situations on its left and proper are true.
Q3. What would be the output of the next code?
print(3 ** 3)
a) 9
b) 27
c) 81
d) 6
Reply: b
Rationalization: The code 3 ** 3 calculates 3 raised to the ability of three, which is the same as 27. Subsequently, the output can be 27.
This fall. What does the expression not(10 == 10) consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: b
Rationalization: The expression 10 == 10 evaluates to True as a result of 10 is certainly equal to 10. The not operator negates this end result, so not(10 == 10) evaluates to False.
Q5. Which operator is used to carry out ground division?
a) %
b) //
c) /
d) **
Reply: b
Rationalization: The // operator in Python is used to carry out ground division, which returns the most important integer lower than or equal to the quotient of the division.
Q6. What would be the output of the next code?
print(9 % 4)
a) 1
b) 2
c) 3
d) 0
Reply: a
Rationalization: The % operator calculates the rest of the division operation. Right here, 9 % 4 ends in 1 as a result of 9 divided by 4 equals 2 with a the rest of 1.
Q7. What does the expression 3 != 3 or 5 > 4 consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: a
Rationalization: The expression 3 != 3 evaluates to False as a result of 3 is certainly equal to three. Nonetheless, 5 > 4 evaluates to True. Since it’s linked by or, if both situation is True, the entire expression evaluates to True.
Q8. What would be the output of the next code?
print(7 // 2)
a) 3.5
b) 4
c) 3
d) 2
Reply: c
Rationalization: The // operator performs ground division, returning the most important integer lower than or equal to the quotient of the division. Right here, 7 // 2 ends in 3.
Q9. What does the expression not(3 < 2) consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: a
Rationalization: The expression 3 < 2 evaluates to False as a result of 3 will not be lower than 2. The not operator negates this end result, so not(3 < 2) evaluates to True.
Q10. Which operator is used to carry out logical AND operation?
a) &
b) &&
c) and
d) AND
Reply: c
Rationalization: The and key phrase is utilized in Python to carry out logical AND operation between two operands.
Q11. What would be the output of the next code?
print(2 ** 0)
a) 1
b) 0
c) 2
d) 3
Reply: a
Rationalization: Any quantity raised to the ability of 0 equals 1. So, 2 ** 0 ends in 1.
Q12. What does the expression 10 == 10 and 5 > 6 consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: b
Rationalization: The expression 10 == 10 evaluates to True as a result of 10 is the same as 10. Nonetheless, 5 > 6 evaluates to False. Since it’s linked by and, each situations have to be True for the entire expression to be True.
Q13. Which operator is used to carry out logical OR operation?
a) |
b) ||
c) or
d) OR
Reply: c
Rationalization: The or key phrase is utilized in Python to carry out logical OR operation between two operands.
Q14. What does the expression (5 != 5) or (6 >= 6) consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: a
Rationalization: The expression (5 != 5) evaluates to False as a result of 5 is the same as 5. Nonetheless, (6 >= 6) evaluates to True. Since it’s linked by or, if both situation is True, the entire expression evaluates to True.
Q15. Which operator is used to carry out bitwise XOR operation?
a) ^
b) ^^
c) xor
d) XOR
Reply: a
Rationalization: The ^ operator in Python is used to carry out bitwise XOR operation between two operands.
Q16. Which operator is used to carry out left shift?
a) <<
b) >>
c) <<>>
d) LSH
Reply: a
Rationalization: The << operator in Python is used to carry out left shift operation on the binary illustration of a quantity.
Q17. What does the expression (6 > 5) or (7 <= 7) consider to?
a) True
b) False
c) Error
d) Not one of the above
Reply: a
Rationalization: Each situations (6 > 5) and (7 <= 7) are True, and since they’re linked by or, the entire expression evaluates to True.
Q18. What’s the results of the next expression in Python?
10 * (3 + 5) // 2
a) 40
b) 35
c) 20
d) 25
Reply: c
Rationalization: Parentheses have increased priority than multiplication, which has increased priority than ground division, so the expression is evaluated as 10 * (3 + 5) // 2, leading to 20.
Q19. What’s the results of the next expression in Python?
8 / 2 + 2 * 3
a) 14
b) 10
c) 12
d) 16
Reply: c
Rationalization: Multiplication and division have the identical priority and are evaluated from left to proper, so the expression is evaluated as 8 / 2 + 2 * 3, leading to 12.
Q20. What’s the results of the next expression in Python?
5 + 2 * 3 ** 2
a) 35
b) 23
c) 25
d) 17
Reply: c
Rationalization: Exponentiation has increased priority than multiplication, which has increased priority than addition, so the expression is evaluated as 5 + (2 * 3 ** 2), leading to 25.
Q21. What’s the results of the next expression in Python?
10 > 5 < 2
a) True
b) False
c) 7
d) Error
Reply: b
Rationalization: Chained comparability operators are evaluated left to proper, so 10 > 5 < 2 evaluates to False.
Q22. What’s the results of the next expression in Python?
3 * "Hiya"
a) “HelloHelloHelloHello”
b) “Hiya 3 instances”
c) “HelloHelloHello”
d) Error
Reply: a
Rationalization: The multiplication (*) operator repeats the string “Hiya” thrice, leading to “HelloHelloHello”.
Q23. What’s the results of the next expression in Python?
-5 // 2
a) -2
b) -3
c) 2
d) 3
Reply: b
Rationalization: Ground division at all times rounds in the direction of unfavorable infinity, so -5 // 2 equals -3.
Q24. What would be the results of the next expression?
8 % 3 + 2 ** 2 * (2 + 2)
a) 21
b) 20
c) 19
d) 18
Reply: b
Rationalization: First, 8 % 3 ends in 2. Then, 2 ** 2 ends in 4. Subsequent, (2 + 2) ends in 4. So, the expression turns into 2 + 4 * 4, which equals 20.
Q25. What does the next expression consider to?
(3 + 2) * 4 / 2 ** 2
a) 12.0
b) 5.0
c) 10.0
d) 6.0
Reply: a
Rationalization: Parentheses are evaluated first, so (3 + 2) turns into 5. Then, 2 ** 2 is 4. After that, 5 * 4 is 20, and at last, 20 / 4 equals 5.0.
Q26. What would be the output of the next code snippet?
x = 5
y = x * 2 if x < 10 else x / 2
print(y)
a) 10
b) 2.5
c) 5
d) 25
Reply: a
Rationalization: Since x is lower than 10, the expression x * 2 is evaluated, leading to 10.
Q27. What does the expression bool(0) consider to?
a) True
b) False
c) None
d) Error
Reply: b
Rationalization: In Python, 0 is taken into account as False when transformed to a boolean utilizing the bool() perform.
Q28. What does the expression len(‘Python’) return?
a) 7
b) 6
c) 8
d) 5
Reply: b
Rationalization: The len() perform returns the size of a string, so len(‘Python’) returns 6.
Q29. What would be the worth of y after executing the next code snippet?
x = 5
y = x if x < 10 else x / 2
a) 5
b) 2.5
c) 10
d) Error
Reply: a
Rationalization: Since x is lower than 10, the worth of y can be x, which is 5
Q30. What’s the output of the expression min(4, -2, 7, 1)?
a) 4
b) -2
c) 7
d) 1
Reply: b
Rationalization: The min() perform returns the smallest of the enter values. So, min(4, -2, 7, 1) returns -2.
Q31. What’s the output of the expression spherical(2.564, 2)?
a) 2.56
b) 2.6
c) 2.57
d) 2.564
Reply: b
Rationalization: The spherical() perform rounds the given quantity to the desired variety of digits after the decimal level. So, spherical(2.564, 2) returns 2.56.
Q32. What’s the output of the expression abs(-5.5)?
a) -5.5
b) 5.5
c) -5
d) 5
Reply: b
Rationalization: The abs() perform returns absolutely the (constructive) worth of a quantity. So, abs(-5.5) equals 5.5.
Q33. What would be the worth of y after executing the next code snippet?
x = 5
y = x if x != 5 else x + 2
a) 5
b) 7
c) 10
d) Error
Reply: b
Rationalization: Since x is the same as 5, the worth of y can be x + 2, which is 7.
Congratulations on finishing the Python Operators and Expressions quiz! We hope you discovered the questions each difficult and informative. Mastering operators and expressions is important for writing environment friendly and error-free Python code. Whether or not you aced the quiz or encountered some challenges, use this expertise to additional improve your understanding of Python programming. Maintain working towards, exploring, and experimenting with Python, and also you’ll proceed to develop as a proficient programmer. Maintain coding and completely satisfied studying!
You may also enroll in out free Python Course Right this moment!
Learn our extra articles associated to MCQs in Python:


