ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

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

Correct answer: A. 1 True -1 -1

Shifts group left to right, so 1 << 31 >> 31 is 1. Right shifting a negative number keeps the sign and rounds toward negative infinity, so -1 >> 31 and -2**31 >> 31 are both -1.

More Python Programming questions

Exams that ask this topic