ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print('%.2f' % 0.125, '%.2f' % 0.375, '%.1f' % 0.05, '%.0f' % 1.5)
  1. A. 0.13 0.38 0.1 2
  2. B. 0.12 0.37 0.1 2
  3. C. 0.12 0.38 0.1 2
  4. D. 0.12 0.38 0.0 2

Correct answer: C. 0.12 0.38 0.1 2

0.125 and 0.375 are exact binary fractions sitting on a tie, so round-half-to-even gives 0.12 and 0.38. 0.05 is stored slightly above its decimal value, so it rounds up to 0.1.

More Python Programming questions

Exams that ask this topic