ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print('%-5s|%5s|' % ('ab', 'cd'), '%(x)d-%(y)s' % {'x': 1, 'y': 'z'})
  1. A. ab | ce| 1-z
  2. B. ab | cd| 1-y
  3. C. ab | dc| 1-z
  4. D. ab | cd| 1-z

Correct answer: D. ab | cd| 1-z

%-5s left-aligns ab in five columns, and %5s right-aligns cd in five columns. The mapping keys x and y fill the named fields, which gives 1 and z.

More Python Programming questions

Exams that ask this topic