ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('{:^6}'.format('ab'), '{:*<4}'.format(1), '{:>3}|{:<3}|'.format('a', 'b'))
  1. A. ab 1*** a|b |
  2. B. ab 2*** a|b |
  3. C. ab 1*** a|c |
  4. D. ac 1*** a|b |

Correct answer: A. ab 1*** a|b |

The centre spec pads the two-character ab to six with two spaces on each side. * fill with < pads 1 on the right, and each field in the last string gets its own alignment.

More Python Programming questions

Exams that ask this topic