ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
s = 'hello world'
print(s.capitalize(), s.title().swapcase(), s.center(15, '*'), s.zfill(13))
  1. A. Hello world Hello Word **hello world** 00hello world
  2. B. Hello world hELLO wORLD **hello world** 00hello world
  3. C. Hello world hELLO wORLD *hello world* 0hello world
  4. D. Hello World hELLO wORLD **hello world** 00hello word

Correct answer: B. Hello world hELLO wORLD **hello world** 00hello world

capitalize uppercases only the first letter, and title followed by swapcase gives hELLO wORLD. center pads the 11-character text to 15 with two stars on each side, and zfill pads with zeros on the left, even before letters.

More Python Programming questions

Exams that ask this topic