ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
n = int('9' * 30)
print(len(str(n + 1)), (n + 1) - 10**30)- A. 31 0
- B. 30 0
- C. 31 1
- D. 30 -1
Correct answer: A. 31 0
n is 10**30 - 1, so n + 1 is 10**30, which has 31 digits. Python integers are unbounded, so the subtraction gives exactly 0 with no overflow.
More Python Programming questions
- What is printed? python print(5 & 3, 5 | 3, 5 ^ 3, ~5, 5 << 2, -5 >> 1)
- What is printed? python print(-1 & 0xFF, -8 >> 1, -1 >> 100, -9 & 7)
- What is printed? python print(1 << 64 == 264, (1 << 64) - 1 & 0xFFFF)
- What is printed? python print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 10) == 0.3, 0.1 + 0.2)
- What is printed? python print(round(2.5), round(3.5), round(-0.5), round(2.675, 2), round(1.005, 2))
- What is printed? python a = float('nan') b = float('nan') print(a == a, a is a, a == b, [a] == [a], [b] == [a])