ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
s = 'hello world'
print(s.title(), s.swapcase()[:5], s.replace('l', '', 2))
  1. A. Hello World HELLO heo world
  2. B. Hello World HELLO heo wold
  3. C. Hello World HELLO heo worl
  4. D. Hello World hELLO he wold

Correct answer: A. Hello World HELLO heo world

title capitalises each word. swapcase on the first five characters gives HELLO. replace with count=2 removes only the first two l's, leaving 'heo world'.

More Python Programming questions

Exams that ask this topic