ProgrammingModerateProduct-company MCQ pattern

What is printed on the first line?

What is printed on the first line?
x = 1
for _ in range(70):
    x *= 2
print(x, x.bit_length(), x == 2**70)
print(x.bit_length() - 1, (x - 1).bit_length())
  1. A. 1180591620717411303424 70 True
  2. B. 1180591620717411303424 71 True
  3. C. 1180591620717411303424 71 False
  4. D. 1180591620717411303423 71 True

Correct answer: B. 1180591620717411303424 71 True

2 to the power 70 needs 71 bits because the top bit is bit 70. Python ints grow as needed, so the loop never overflows.

More Python Programming questions

Exams that ask this topic