ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(1 << 2 + 1, (1 << 2) + 1, 4 >> 1 - 1, 2 * 3 % 4 ** 2 // 3)
  1. A. 8 5 2 2
  2. B. 2 5 4 2
  3. C. 8 5 4 2
  4. D. 8 5 4 6

Correct answer: C. 8 5 4 2

Addition binds tighter than shifts, so 1 << 2 + 1 is 1 << 3. Inside the last expression ** comes first, then * % and // from left to right, giving 6 % 16 // 3 = 2.

More Python Programming questions

Exams that ask this topic