ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(2**53 == float(2**53), 2**53 + 1 == float(2**53 + 1), 2**53 + 2 == float(2**53 + 2))
- A. True True True
- B. False False True
- C. True False False
- D. True False True
Correct answer: D. True False True
2**53 is exact in a double. 2**53 + 1 is not representable, so it rounds to 2**53 and the exact int comparison fails. 2**53 + 2 is representable and compares equal.
More Python Programming questions
- What is printed? python s = 'atbnc' print(len(s), s.split(), s.split('n'), repr(s.split()[0]))
- What is printed? python from fractions import Fraction print(Fraction(3, 6), Fraction('0.75'), Fraction(0.75), Fraction(1, 3) +…
- What is printed? python print(divmod(7, 2.5), divmod(-7.5, 2))
- What is printed? python print(0.1 + 0.1 + 0.1 == 0.3, 0.1 + 0.1 + 0.1, 0.3 == 3 0.1)
- What is printed? python print(bin(5 ^ 3), bin(-5 & 0b1111), int('-0b101', 2))
- What is printed? python print(2 -1, 2 -1074 > 0, 10 -3 == 0.001, 10 -2)