ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(0xFF >> 4 << 4 == 0xF0, 1 << 63 > 0, (1 << 63) - 1 == 2**63 - 1, -(1 << 63) >> 63)
  1. A. True True True 0
  2. B. False True True -1
  3. C. True False True -1
  4. D. True True True -1

Correct answer: D. True True True -1

Right shift on a negative int floors, so -(2**63) >> 63 is -1 rather than 0. Shifts on Python ints do not wrap at 64 bits.

More Python Programming questions

Exams that ask this topic