ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(round(12345, -2), round(12350, -2), round(12250, -2), round(-1234.5, -1))
  1. A. 12300 12400 12300 -1230.0
  2. B. 12300 12400 12200 -1230.0
  3. C. 12300 12300 12200 -1230.0
  4. D. 12300 12400 12200 -1230

Correct answer: B. 12300 12400 12200 -1230.0

With a negative ndigits, round works on the tens or hundreds place and still uses half-to-even, so 12350 goes to 12400 and 12250 goes to 12200. Rounding a float keeps the result a float.

More Python Programming questions

Exams that ask this topic