ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(int(float('1e16')) + 1, float(int(2**60) + 1) == float(2**60))- A. 10000000000000001 True
- B. 10000000000000000 True
- C. 10000000000000001 False
- D. 10000000000000002 True
Correct answer: A. 10000000000000001 True
1e16 converts to the exact int 10**16, and adding 1 gives 10000000000000001. 2**60 + 1 needs more than 53 bits, so converting it to float rounds to 2**60 and the comparison is True.
More Python Programming questions
- What is printed? python print('a-bc d'.split('-'), 'a-bc d'.replace('-', ' ').split(''), 'a-b'.partition('-')[0])
- What is printed? python print(sum([1] 105) == 105, sum([0.5] 105) == 5e4, 1/3 + 1/3 + 1/3 == 1.0, 0.7 + 0.2 + 0.1 == 1.0)
- What is printed? python from fractions import Fraction print(Fraction(7, 3) > 2, float(Fraction(7, 3)), Fraction(7, 3) // 1, Fraction(-7…
- What is printed? python print(1 + 2 3 2 // 4 % 5, (1 + 2) 3 2 // 4 % 5, -2 2, (-2) 2)
- What is printed? python print(max('zebra', 'Zebra'), min('zebra', 'Zebra'), 'apple' > 'Apple', 'Z' < 'a')
- What is printed? python x = 5 print(x.add(3), (5).mod(-3), (-5).mod(3), int.floordiv(-5, 3))