ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
s = 'hello world'
print(s.count('o'), s.index('o', 5), s.title().split()[1][::-1])
  1. A. 2 7 dlroW
  2. B. 2 4 dlroW
  3. C. 2 7 World
  4. D. 1 7 dlroW

Correct answer: A. 2 7 dlroW

'o' appears twice, and searching from index 5 finds the one at index 7. title() makes 'World', and reversing it gives 'dlroW'.

More Python Programming questions

Exams that ask this topic