ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: C. 0 0 2 -2

round sends ties to the nearest even integer. -0.5 and 0.5 go to 0, and 1.5 and -1.5 go to 2 and -2.

More Python Programming questions

Exams that ask this topic