ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: A. 6 6 6 28

Shifts bind tighter than & and |, so 3 << 1 is 6 and 7 & 6 is 6. 1 << 2 is 4, and 6 | 4 is 6, while (6 | 1) << 2 is 7 << 2 = 28.

More Python Programming questions

Exams that ask this topic