ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(1e16 == 10**16, 1e16 + 1 == 10**16 + 1, 1e16 + 2 == 10**16 + 2, int(1e16) + 1)
- A. True True True 10000000000000001
- B. True False True 10000000000000001
- C. True False False 10000000000000000
- D. False False True 10000000000000001
Correct answer: B. True False True 10000000000000001
1e16 is exact, so the first check is True. 1e16 + 1 is not representable and rounds back, so the exact comparison with 10**16 + 1 fails. 1e16 + 2 is representable, and int(1e16) + 1 is exact.
More Python Programming questions
- What is printed? python print('%.2e' % 0, '%.1f' % 2.25, '%.1f' % 2.35, '%5.1f|' % -0.04)
- What is printed? python x = 0.1 print((0.5).asintegerratio(), (0.1).asintegerratio()[1] == 255)
- What is printed? python import operator print(operator.index(5), operator.mod(-7, 3), operator.floordiv(-7, 3))
- What is printed? python print(sorted(['b', 'B', 'a', 'A'], key=lambda s: s.swapcase()))
- What is printed? python print(len(set('mississippi')), sorted(set('mississippi')))
- What is printed? python print(7 -1 == 1 / 7, pow(7, -1, 13) 7 % 13, (7 2) % 13, 2 3 2 % 10)