ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print(round(2.5), round(3.5), round(-0.5), round(2.675, 2), round(1.005, 2))
  1. A. 2 4 -1 2.67 1.0
  2. B. 2 4 0 2.67 1.0
  3. C. 2 4 0 2.68 1.01
  4. D. 3 4 0 2.67 1.0

Correct answer: B. 2 4 0 2.67 1.0

round uses round-half-to-even, so 2.5 becomes 2 and 3.5 becomes 4, and -0.5 becomes 0. 2.675 and 1.005 are stored just below the halfway point, so they round down to 2.67 and 1.0.

More Python Programming questions

Exams that ask this topic