ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print('{0:.2%}'.format(0.12345), '{:,}'.format(1234), '{:e}'.format(0), '{:.0f}'.format(0.5))
  1. A. 12.34% 1,234 0.000000e+00 0
  2. B. 12.35% 1234 0.000000e+00 0
  3. C. 12.35% 1,234 0.000000e+00 1
  4. D. 12.35% 1,234 0.000000e+00 0

Correct answer: D. 12.35% 1,234 0.000000e+00 0

0.12345 is stored a little above the midpoint, so two decimal places of the percentage round up to 12.35%. The .0f format uses round-half-to-even, so 0.5 becomes 0.

More Python Programming questions

Exams that ask this topic