ProgrammingVery hardProduct-company MCQ pattern

What is printed?

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

Correct answer: D. 5 5 5 3

In Python & binds tighter than ^, which binds tighter than |. So 5 & 6 | 1 is (4) | 1 = 5, 5 ^ (6 & 1) = 5, and 1 | (2 ^ (3 & 4)) = 3.

More Python Programming questions

Exams that ask this topic