ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print('ab'.rjust(5, '*'), 'ab'.ljust(5, '-'), 'ab'.center(5, '.'), 'ab'.center(6, '.'))
  1. A. ***ab ab--- ..ab. ..ab..
  2. B. ***ab ba--- ..ab. ..ab..
  3. C. ***ba ab--- ..ab. ..ab..
  4. D. ***ab ab--- ..ba. ..ab..

Correct answer: A. ***ab ab--- ..ab. ..ab..

rjust and ljust pad with the given fill character on the left or right. center puts the extra padding character on the left when the total padding is odd.

More Python Programming questions

Exams that ask this topic