ProgrammingHardGATE CS & IT · Infosys

What is printed?

What is printed?
print(-1 >> 1, -8 >> 2, 1 << 70 > 10**20, (-5) & 0xF)
  1. A. 0 -2 True 11
  2. B. -1 -2 True 11
  3. C. -1 -2 False 11
  4. D. -1 -2 True 5

Correct answer: B. -1 -2 True 11

Right shift on a negative number is arithmetic, so -1 stays -1 and -8 >> 2 is -2. 1 << 70 is far larger than 10^20, and (-5) & 0xF is 11 in two's complement.

More Python Programming questions

Exams that ask this topic