Python Operators Questions and Answers

Practice Mode
Showing 10 of 26 questions
Q11
What is the output of 2 ** 3 ** 2?
  • A 64
  • B 512
  • C 36
  • D 12
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?
  • A contains
  • B in
  • C has
  • D member
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?
  • A 5
  • B 5.0
  • C 2
  • D 2.0
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?
  • A **
  • B +
  • C =
  • D None of these
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"?
  • A True
  • B False
  • C Error
  • D None
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?
  • A ||
  • B or
  • C |
  • D &
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?
  • A 3.5
  • B 3
  • C 4
  • D 1
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?
  • A &&
  • B AND
  • C and
  • D &
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?
  • A Equality
  • B Inequality
  • C Assignment
  • D Identity
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?
  • A 9
  • B 7
  • C 8
  • D 6
Answer: Option B
Explanation: According to operator precedence, multiplication (*) has higher precedence than addition (+), so 3 * 2 is evaluated first, then + 1.
Questions and Answers for Competitive Exams Various Entrance Test