ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(format(1234567.891, ',.2f'), format(0.000123, 'e'), format(12, '>5'), format(3, '03'))
  1. A. 1,234,567.89 1.230000e-04 12 003
  2. B. 1,234,567.89 1.23e-04 12 003
  3. C. 1,234,567.89 1.230000e-04 12 3
  4. D. 1,234,567.8 1.230000e-04 12 003

Correct answer: A. 1,234,567.89 1.230000e-04 12 003

The comma flag groups thousands and .2f rounds to two decimals. The e format uses six decimals by default, and the > width 5 pads 12 with three spaces. A width of 03 pads the integer 3 with a leading zero.

More Python Programming questions

Exams that ask this topic