ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(0b1010 & ~0b10, 0b1010 ^ 0b1111, 1 << 3 | 1, 6 & 3 == 2)
  1. A. 8 5 9 True
  2. B. 8 5 9 False
  3. C. 8 5 0 True
  4. D. 8 5 9 1

Correct answer: A. 8 5 9 True

~0b10 clears bit 1, so 1010 & ...11101 is 1000 = 8. The comparison 6 & 3 == 2 is True because & binds tighter than == in Python, and 6 & 3 is 2.

More Python Programming questions

Exams that ask this topic