ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(1e20) == 10**20, int(1e20 + 1) == 10**20 + 1, int(1e20) - 10**20)
- A. True True 0
- B. False False 0
- C. True False 0
- D. True False 1
Correct answer: C. True False 0
1e20 is exactly representable, so int(1e20) equals 10**20. Adding 1 to the float has no effect at this magnitude, so the second comparison is False.
More Python Programming questions
- What is printed? python print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])
- What is printed? python s = 'x' t = s s = s + 'y' print(t, s, t is s)
- What is printed? python print(''.join(map(chr, [72, 105])), ord('A') > 127, len('ab'.encode('utf-8')))
- What is printed? python print(list('hi'.encode('utf-16-le')), len('hi'.encode('utf-32')))
- What is printed? python print(bytes([104, 105]).decode(), bytes(b'ab').hex(), bytes([10, 255]).hex())