🎙 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 5 of 10

What happens when you call a generator function?

What happens when you call a generator function?

  1. A.Its body runs to the end immediately
  2. B.It returns the first yielded value
  3. C.It returns a generator object; the body runs only when values are requested
  4. D.It raises StopIteration
Answer & explanation

Correct answer: It returns a generator object; the body runs only when values are requested

The body starts running at the first next() call.

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 →