ProgrammingVery hardCAT · MBA placement

What is printed?

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

Correct answer: A. 0 2 2 0 2.67

round with no digits uses round-half-to-even, so 0.5 goes to 0 and 2.5 goes to 2. round(2.675, 2) prints 2.67 because 2.675 is stored slightly below its decimal value.

More Python Programming questions

Exams that ask this topic