ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(0b1 << 100 > 2**99, (1 << 100).bit_length(), len(bin(1 << 100)) - 2)
  1. A. False 101 101
  2. B. True 100 101
  3. C. True 101 101
  4. D. True 101 100

Correct answer: C. True 101 101

1 << 100 is 2**100, which is above 2**99. The number 2**100 needs 101 bits, and bin() prints '0b' followed by 101 digits.

More Python Programming questions

Exams that ask this topic