ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print(round(0.125, 2), round(2.675, 2), round(-1.5), round(25, -1), round(35, -1))
  1. A. 0.12 2.67 -2 20 40
  2. B. 0.13 2.68 -2 30 40
  3. C. 0.12 2.68 -1 20 40
  4. D. 0.13 2.67 -2 30 40

Correct answer: A. 0.12 2.67 -2 20 40

round uses round-half-to-even on the exact binary value: 0.125 is exact and ties to 0.12; 2.675 is really 2.67499..., so 2.67; -1.5 ties to -2; 25 ties to 20 and 35 to 40.

More Python Programming questions

Exams that ask this topic