ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(sum(1 for c in 'hello world' if c in 'aeiou'))
  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 5

Correct answer: A. 3

The vowels in hello world are e, o and o, so the generator counts 3.

More Python Programming questions

Exams that ask this topic