LearnFrenzy
Sign in Take a free test

Iterators and Generators · Iterators and Generators MCQ · Question 5

Calling a generator function Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

What happens when you call a generator function such as gen = countdown(3)?

  • A The body runs completely and the values are stored
  • B A generator object is returned and none of the body runs yet Correct
  • C The body runs until the first yield
  • D It raises StopIteration
Correct Answer: Option B

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

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links