ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(round(7.5), round(6.5), round(-7.5), round(7.5000001))
  1. A. 8 6 -8 7
  2. B. 8 6 -7 8
  3. C. 7 6 -8 8
  4. D. 8 6 -8 8

Correct answer: D. 8 6 -8 8

Exact halves go to the even neighbour, so 7.5 becomes 8 and 6.5 becomes 6. 7.5000001 is above the half-way point and rounds up to 8.

More Python Programming questions

Exams that ask this topic