ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
print(int(float('9007199254740993')) == 9007199254740993, float('9007199254740993') == 9007199254740992.0, int(float(2**53 + 3)) == 2**53 + 4)- A. False True True
- B. True True True
- C. False False True
- D. False True False
Correct answer: A. False True True
9007199254740993 is 2**53 + 1, which is not representable as a double, so it rounds to 2**53. 2**53 + 3 is halfway between two doubles and rounds to the even neighbour 2**53 + 4.
More Python Programming questions
- What is printed? python nums = [3, 1, 4, 1, 5, 9, 2, 6] print(sorted(nums)[len(nums) // 2], sorted(nums)[(len(nums) - 1) // 2], sum(nums)…
- What is printed? python print(sum([0.1] 3) == 0.3, sum([0.1] 3, 0.0) == 0.30000000000000004, sum([1e100, 1.0, -1e100]))
- What is printed? python print(-(2 3) 2, (-2) 3 2, -2 -1, 0)
- What is printed? python print(7 & 3 << 1, 7 & (3 << 1), 6 | 1 << 2, (6 | 1) << 2)
- What is printed? python print(~0, ~-1, -~0, ~~5, -~-5)
- What is printed? python print(max(map(int, '3 17 9'.split())), min(map(int, '3 17 9'.split())), sorted('3 17 9'.split())[-1])