ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(sum(1 for c in 'Hello World' if c.isupper()), 'Hello World'.count('o'))
  1. A. 2 1
  2. B. 2 3
  3. C. 2 2
  4. D. 1 2

Correct answer: C. 2 2

Only the capital letters H and W are uppercase, which gives 2. 'o' appears once in Hello and once in World.

More Python Programming questions

Exams that ask this topic