ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(1e22) == 10**22, int(1e23) == 10**23, 1e23 == 10**23, float(10**23) == 1e23)
- A. True False False True
- B. True True True True
- C. True False True True
- D. False False False True
Correct answer: A. True False False True
1e22 is exactly representable, but 1e23 is not, so int(1e23) is 99999999999999991611392 rather than 10**23. Comparing a float with an int is exact, so 1e23 == 10**23 is False, while float(10**23) rounds to the same double as 1e23.
More Python Programming questions
- What is printed? python print(0.1 + 0.7, 0.1 7, round(0.1 7 10), 3 0.1 == 0.30000000000000004)
- What is printed? python print((-1) 0.5, (-1) 2, (-8) (1 / 3), -1 0.5)
- Which three lines are printed? python import sys print(sys.getintmaxstrdigits()) try: int('1' 5000) print('parsed') except ValueError…
- What is printed? python import math print(math.isclose(0.1 + 0.2, 0.3), math.isclose(1e-12, 0), math.isclose(1e-12, 0, abstol=1e-9))
- What is printed? python print(int('١٢٣') + 1, 'ß'.upper(), 'Dž'.lower(), len('ß'.upper()))
- What is printed? python total = 0.0 for in range(10): total += 0.1 print(total, total == 1.0, sum([0.1] 10) == 1.0)