ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(len(bin(10 ** 6)) - 2, len(bin(2 ** 20)) - 2)
  1. A. 20 21
  2. B. 20 20
  3. C. 19 21
  4. D. 21 21

Correct answer: A. 20 21

10**6 is below 2**20 and at least 2**19, so it has 20 bits. 2**20 itself has 21 bits.

More Python Programming questions

Exams that ask this topic