ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(sum(range(10**6)) == 10**6 * (10**6 - 1) // 2, 2**0.5 * 2**0.5 == 2.0, 2**0.5 * 2**0.5)
- A. True True 2.0000000000000004
- B. True False 2.0000000000000004
- C. False False 2.0000000000000004
- D. True False 2.0
Correct answer: B. True False 2.0000000000000004
The integer sum matches the closed formula exactly because Python ints do not overflow. Square roots are inexact in binary floating point, so the product is 2.0000000000000004 rather than 2.0.
More Python Programming questions
- What is printed? python print(int(2.9999999999999996), float('1e400'), -float('1e400'), 1e308 10 == float('inf'))
- What is printed? python print(10 % 3.5, -10 % 3.5, 10 // 3.5, round(-1.5), round(0.5) + round(1.5))
- What is printed? python print(divmod(7.5, 2), 7.5 % -2, -7.5 // 2)
- What is printed? python print(f'{0.1:.20f}'[:12], f'{2/3:.3f}', f'{1e22:.0f}', f'{1e23:.0f}')
- What is printed? python print(float(' 10.5 '), float('infinity'), float('-nan') != float('-nan'), float('10'))
- What is printed? python print(len(bytes(3)), bytes([65, 66]) == b'AB', bytearray(b'ab') == b'ab', type(b'a'[0]).name)