ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
print(2**53 + 1 == 2**53 + 1.0, 2**53 + 1 == 2**53, float(2**53 + 1) == 2**53)
- A. True False True
- B. False True True
- C. False False False
- D. False False True
Correct answer: D. False False True
The int 2**53 + 1 is exact, but 2**53 + 1.0 is a float that rounds to 2**53, and the int/float comparison is exact, so the first test is False. Converting the int to float first rounds down to 2**53, making the last test True.
More Python Programming questions
- What is printed? python pairs = [(2, 'b'), (1, 'z'), (2, 'a'), (1, 'y')] print(sorted(pairs, key=lambda t: t[0])) print(sorted(pairs…
- What is printed on the second line? python words = ['pear', 'fig', 'apple', 'kiwi', 'date'] print(sorted(words, key=lambda w: (-len(w)…
- What is printed? python print(('ab' 3).count('aba'), 'ababa'.count('aba'), 'aaaa'.count('aa'))
- What is printed on the third line? python print('a,b,,c'.split(',')) print(' a b '.split()) print(' a b '.split(' '))
- What is printed? python print(int('0x1f', 16), int('0x1f', 0), int(' -12 '), int('1000'))
- What is printed? python print(bin(-5), format(-5, '08b'), (-5) & 0xFF, format(-5 & 0xFF, '08b'))