ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print('%.3f' % 1.0005, '%.1f' % 0.25, '%.1f' % 0.35, round(0.35, 1))
  1. A. 1.001 0.2 0.3 0.3
  2. B. 1.000 0.3 0.3 0.3
  3. C. 1.000 0.2 0.3 0.3
  4. D. 1.000 0.2 0.4 0.4

Correct answer: C. 1.000 0.2 0.3 0.3

1.0005 is stored a little below the midpoint, so it rounds down. 0.25 is exact and ties to even giving 0.2, while 0.35 is stored just below its midpoint and gives 0.3.

More Python Programming questions

Exams that ask this topic