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())- A. 1180591620717411303424 70 True
- B. 1180591620717411303424 71 True
- C. 1180591620717411303424 71 False
- 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
- What is printed on the first line? python import math print(math.factorial(20) == 2432902008176640000, len(str(math.factorial(25))))…
- What is printed on the first line? python n = 264 print(n, n.bitlength(), hex(n - 1), oct(8), bin(5)) print(int(hex(n)[2:], 16) == n, -263…
- What is printed on the first line? python print(int('1' 19) + 1, 1018 10, 9223372036854775807 + 1 > 263 - 1) print(2100 // 298, (2100) >>…
- What is printed? python print(0b1111 ^ 0b1010 & 0b0110, (0b1111 ^ 0b1010) & 0b0110, 6 & 3 | 4 ^ 1)
- What is printed? python print(1 << 2 + 1, (1 << 2) + 1, 4 >> 1 - 1, 2 3 % 4 2 // 3)
- What is printed on the first line? python print(0.5 + 0.25 == 0.75, 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0)…