ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
x = 10
print(x.bit_length(), (x >> 1).bit_length(), (x << 3) // 16)
  1. A. 4 4 5
  2. B. 3 3 5
  3. C. 4 3 10
  4. D. 4 3 5

Correct answer: D. 4 3 5

10 is 1010, which has 4 bits. 10 >> 1 is 5, which needs 3 bits. 10 << 3 is 80, and 80 // 16 is 5.

More Python Programming questions

Exams that ask this topic