ProgrammingVery hardCAT · MBA placement

What is printed?

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

Correct answer: C. 2 4 0 1

round() uses round-half-to-even only for exact halves, so 2.5 becomes 2 and 3.5 becomes 4. The int result of round(-0.5) is 0, and 0.5 + 1e-16 is slightly above one half, so it rounds up to 1.

More Python Programming questions

Exams that ask this topic