ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(6 & 3 == 2, 5 | 2 == 7)
  1. A. False True
  2. B. True False
  3. C. True True
  4. D. 0 0

Correct answer: C. True True

In Python, & and | bind tighter than ==, so 6 & 3 == 2 means (6 & 3) == 2, which is True. C parses the same expression differently, which is the trap.

More Python Programming questions

Exams that ask this topic