ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print('{0:>{1}}'.format('x', 3), '{:0>3}'.format(7), '{:x<4}'.format('ab'), '{:^7.3f}|'.format(2.5))
  1. A. x 007 abxx 2.500 |
  2. B. x 007 abxx 2.600 |
  3. C. x 007 abxx 2.5 |
  4. D. x 700 abxx 2.500 |

Correct answer: A. x 007 abxx 2.500 |

The nested width 3 right-aligns x, and the 0 fill with > alignment pads 7 to 007. The x fill pads ab on the right, and the centred 2.500 in seven columns gets one space on each side.

More Python Programming questions

Exams that ask this topic