ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(1e15 + 0.3) == 10**15, round(1e15 + 0.3) - 10**15)
- A. False 0
- B. True 1
- C. True 0
- D. True 0.25
Correct answer: C. True 0
1e15 + 0.3 is stored as 1000000000000000.25, so int truncates to 10**15 and round gives the same integer. The difference is 0.
More Python Programming questions
- What is printed? python print(10.01, 0x1F, 1000.0e-3)
- What is printed? python print(str(1e100)[:6], len(str(1e100)), 1e100 == 10100)
- What is printed? python print(divmod(-1, 1020), divmod(1020, -1))
- What is printed? python print(int(1e20) == 1020, int(1e20 + 1) == 1020 + 1, int(1e20) - 1020)
- What is printed? python print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])