ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print('%5s|%-5s|' % ('ab', 'cd'))
  1. A. ab|dc |
  2. B. ba|cd |
  3. C. ab|cd |
  4. D. ab|ce |

Correct answer: C. ab|cd |

%5s right-aligns ab in five columns, and %-5s left-aligns cd in five columns, padding on the right. Both fields are padded to exactly five characters.

More Python Programming questions

Exams that ask this topic