ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(round(0.5), round(1.5), round(2.5), round(-2.5), round(2.5 + 1e-15))
  1. A. 0 2 2 -2 3
  2. B. 0 2 2 -2 2
  3. C. 1 2 2 -2 3
  4. D. 0 2 2 -3 3

Correct answer: A. 0 2 2 -2 3

round uses half-to-even at exact halves, so 0.5 becomes 0 and 2.5 becomes 2. Adding a tiny 1e-15 pushes 2.5 past the halfway point, so it rounds to 3.

More Python Programming questions

Exams that ask this topic