ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(sum(1 for c in 'hello world' if c in 'aeiou'))
- A. 3
- B. 2
- C. 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
- What is printed? python print(list(filter(lambda x: x > 0, map(lambda x: x - 2, [1, 2, 3, 4]))))
- What is printed? python print(1e3, 1000.0 == 1e3, 10 -2)
- What is printed? python print(type(True + 1).name, type(2 1.0).name)
- What is printed? python print(list(enumerate(['x'], 1))[0][0] + 1)
- What is printed? python print(list('ab') == ['a', 'b'], 'ab' == ['a', 'b'])
- What is printed? python print(len(dict.fromkeys('aab')), list(dict.fromkeys('aab')))