ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
a = 10 ** 16 print(float(a + 1) == float(a), int(float(2 ** 53 + 1)) - 2 ** 53, 2 ** 53 + 1.0 == 2 ** 53)
- A. True 0 True
- B. False 1 False
- C. True 1 True
- D. False 0 True
Correct answer: A. True 0 True
A float has a 53-bit significand, so integers above 2^53 are not all representable: 10^16 + 1 and 2^53 + 1 round to their even neighbours. Python ints themselves are exact; the loss happens on conversion to float.
More Python Programming questions
- What is printed? python print(divmod(-17, 5), divmod(17, -5), -17 % -5, pow(3, -1, 7))
- What is printed? python print(not 1 == 2, not (1 == 2) is True, (not 1) == 2, 1 + True + True)
- What is printed? python x = 5 print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
- What is printed? python s = "a,b,,c," print(len(s.split(",")), len(s.split()), s.rsplit(",", 2)[0], s.partition(";")[0] == s)
- What is printed? python s = "a btcn" print(s.split(), len(s.split(" ")), len(s.strip(" ")), len(s.strip()))
- What is printed? python print("ß".upper(), "ß".casefold() == "SS".casefold(), "fi".upper(), len("ß".upper()))