Python Operators Questions and Answers

Practice Mode
Showing 10 of 26 questions
Q21
Which operator performs bitwise XOR?
  • A xor
  • B ^
  • C ~
  • D !
Answer: Option B
Explanation: The ^ operator performs bitwise XOR (exclusive OR) operation, which sets each bit to 1 if only one of the two bits is 1.
Q22
What is the result of 2 + 3 * 4?
  • A 20
  • B 14
  • C 24
  • D 10
Answer: Option B
Explanation: Multiplication has higher precedence than addition, so 3 * 4 is evaluated first (12), then 2 + 12 = 14.
Q23
Which operator is used for logical NOT?
  • A !
  • B NOT
  • C not
  • D ~
Answer: Option C
Explanation: The "not" operator is used for logical negation in Python, reversing the boolean value of an expression.
Q24
What is the output of (2 + 3) * 4?
  • A 20
  • B 14
  • C 24
  • D 10
Answer: Option A
Explanation: Parentheses have the highest precedence, so (2 + 3) is evaluated first (5), then 5 * 4 = 20.
Q25
Which operator performs bitwise left shift?
  • A <<
  • B >>
  • C <
  • D >
Answer: Option A
Explanation: The << operator performs bitwise left shift, moving bits to the left and filling with zeros on the right.
Q26
What is the result of 8 >> 1?
  • A 4
  • B 8
  • C 16
  • D 2
Answer: Option A
Explanation: The >> operator performs bitwise right shift. 8 in binary is 1000, right shifting by 1 gives 100 which is 4 in decimal.
Questions and Answers for Competitive Exams Various Entrance Test