ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(round(-2.5), round(-3.5), round(-2.5 - 1e-9))
- A. -2 -4 -3
- B. -3 -4 -3
- C. -2 -3 -3
- D. -2 -4 -2
Correct answer: A. -2 -4 -3
Exact halves go to the even neighbour, so -2.5 becomes -2 and -3.5 becomes -4. Subtracting a tiny amount moves -2.5 past the midpoint, so it rounds to -3.
More Python Programming questions
- What is printed? python print(7 -1 7, (7 -1) 7 == 1.0)
- What is printed? python print(int('0o777', 8) == 511, int('777', 8) - int('0o777', 0))
- What is printed? python print(len('%d' % -0), '%d' % -0.0, '%.1f' % -0.0)
- What is printed? python print(max('abc', 'abd', key=lambda s: s[::-1]), min('ba', 'ab', key=len))
- What is printed? python print(sorted([1, 10, 2], key=lambda x: str(x)[0]))
- What is printed? python print(0.1 + 0.1 == 0.2, 0.1 + 0.1 + 0.1 == 0.3, 0.2 + 0.2 == 0.4)