ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(bin(0b1010 << 2 >> 1 & 0xF), 0o17 + 0x1F + 0b11, 0x_ff, 1_0j)
  1. A. 0b100 49 255 10j
  2. B. 0b1010 49 255 10j
  3. C. 0b100 46 255 10j
  4. D. 0b100 49 255 1_0j

Correct answer: A. 0b100 49 255 10j

<< and >> share one precedence level and go left to right, so ((0b1010 << 2) >> 1) & 0xF gives 0b100. Underscores are allowed in literals, so 1_0j is the imaginary number 10j.

More Python Programming questions

Exams that ask this topic