ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

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

Correct answer: D. 2 -2 2

round uses half to even on exact halves, so 1.5 goes to 2 and -1.5 goes to -2. 2.4999 is below the halfway point and rounds down to 2.

More Python Programming questions

Exams that ask this topic