🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Iterators and Generators: all 10 questions

Quiz: Iterators and Generators · Question 6 of 10

What does this print? (code)

What does this print?

def f():
    for i in range(3):
        yield i * 10
print(sum(f()))
  1. A.3
  2. B.30
  3. C.0
  4. D.[0, 10, 20]
Answer & explanation

Correct answer: 30

The values are 0, 10 and 20; their sum is 30.

Can you get the rest right without peeking?

Take the timed Quiz: Iterators and Generators quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →