ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(float(2**54) + 1 == 2**54, 2**54 + 1 == float(2**54), 1e16 + 2 == 1e16 + 1)
- A. False False False
- B. True True False
- C. True False False
- D. True False True
Correct answer: C. True False False
2**54 + 1 is not representable as a double, so the float rounds back to 2**54 and the first test is True. The int comparison is exact, so 2**54 + 1 is not equal to float(2**54).
More Python Programming questions
- What is printed? python print(int('١٢٣'), int('0' 2 + '5'), int('5' + '0' 2), int(' t7n'))
- What is printed? python print(bin(-8 & 0xFF), (-8) >> 1, (-8) // 2, (-9) // 2, -9 >> 1)
- What is printed? python print(x := 7, x 2, [y := 3, y + 1])
- What is printed? python print('%s|%r' % ("it's", "it's"))
- What is printed? python print(ord('a') - ord('A'), chr(ord('A') + 32), 'Z'.lower() < 'a', 'z' > 'Z')
- What is printed? python print('-'.join('abc'), ''.join(map(str, [1, 2, 3])) == '123', ','.join([]) == '', 'x'.join(['', '']))