ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: B. 7

In Python & binds tighter than ^, and ^ binds tighter than |. So the expression is (7 & 3) | (4 ^ 1) = 3 | 5 = 7.

More Python Programming questions

Exams that ask this topic