ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(-1 & 0xFF, -8 >> 1, -1 >> 100, -9 & 7)
  1. A. 255 -4 -1 -9
  2. B. -1 -4 -1 7
  3. C. 255 -4 -1 7
  4. D. 255 -5 -1 7

Correct answer: C. 255 -4 -1 7

Python ints act like infinite two's complement, so -1 & 0xFF keeps the low eight bits (255), -8 >> 1 is -4, shifting -1 right stays -1, and -9 & 7 is 7 because -9 ends in the bits 0111.

More Python Programming questions

Exams that ask this topic