ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(str(1.1 * 1.1), str(1.21), 1.1 * 1.1 == 1.21, abs(1.1 * 1.1 - 1.21) < 1e-12)
- A. 1.21 1.21 True True
- B. 1.2100000000000002 1.21 True True
- C. 1.2100000000000002 1.21 False False
- D. 1.2100000000000002 1.21 False True
Correct answer: D. 1.2100000000000002 1.21 False True
1.1 * 1.1 is a little above 1.21 in binary, so its shortest repr shows the extra digit. The tolerance check succeeds because the error is far below 1e-12.
More Python Programming questions
- What is printed? python print(10 2 == 100.0, 2 0.5 2 == 2 0.25, pow(4, 0.5))
- What does ','.join([1, 2]) do in Python 3?
- Which statement about the heapq module is correct?
- What is printed? python print(sum(range(1, 10 5 + 1, 7)))
- What is printed? python print(pow(7, 222, 13), pow(7, 6, 13))
- What is printed? python print(max(map(len, ['ab', 'cde', 'f'])), sorted([[2, 1], [1, 5], [1, 2]]))