ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print('%(a)s-%(b)05.1f' % {'a': 'x', 'b': 3.14159})
  1. A. x-3.1
  2. B. x-003.1
  3. C. x-0003.1
  4. D. x-03.14159

Correct answer: B. x-003.1

%05.1f formats 3.14159 with one decimal place, giving 3.1, and pads it with zeros to width five to give 003.1. The mapping key a is looked up by the name in parentheses.

More Python Programming questions

Exams that ask this topic