Python Operators Questions and Answers
Practice ModeShowing 10 of 26 questions
Q11
What is the output of 2 ** 3 ** 2?
Answer: Option B
Explanation: Exponentiation has right-to-left associativity. So 2 ** 3 ** 2 is evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512.
Q12
Which operator is used for membership testing?
Answer: Option B
Explanation: The "in" operator is used to check if a value exists in a sequence (like list, tuple, string, etc.).
Q13
What is the result of 10 / 2?
Answer: Option B
Explanation: The / operator always returns a float in Python, even if the result is a whole number.
Q14
Which operator has left-to-right associativity?
Answer: Option B
Explanation: Most operators in Python have left-to-right associativity, including arithmetic operators like +, -, *, /.
Q15
What is the output of "a" in "apple"?
Answer: Option A
Explanation: The "in" operator checks if a substring exists in a string. "a" is indeed in "apple".
Q16
Which operator performs bitwise OR?
Answer: Option C
Explanation: The | operator performs bitwise OR operation, which sets each bit to 1 if one of the two bits is 1.
Q17
What is the result of 7 // 2?
Answer: Option B
Explanation: Floor division returns the largest integer less than or equal to the result. 7 รท 2 = 3.5, so floor division gives 3.
Q18
Which operator is used for logical AND?
Answer: Option C
Explanation: The "and" operator is used for logical AND operations in Python, not && like in some other languages.
Q19
What does the != operator check?
Answer: Option B
Explanation: The != operator checks for inequality, returning True if the operands are not equal.
Q20
What is the output of 3 * 2 + 1?
Answer: Option B
Explanation: According to operator precedence, multiplication (*) has higher precedence than addition (+), so 3 * 2 is evaluated first, then + 1.