Python: Which statement about Iterators, Generators, and yield is the strongest interview answer?

Difficulty:

Easy

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

Which statement about Iterators, Generators, and yield is the strongest interview answer?

  1. Iterators, Generators, and yield is mostly a naming style choice and has little effect on runtime behavior or design tradeoffs.
  2. Iterators produce values one at a time, and generator functions use yield to suspend and resume that production lazily.
  3. Iterators, Generators, and yield exists mainly to reduce the number of files in a Python project.
  4. Iterators, Generators, and yield matters only for frontend scripting and not for backend or automation code.

Hint

Start with the core rule behind Iterators, Generators, and yield.

Answer and rationale

Correct answer: B. Iterators produce values one at a time, and generator functions use yield to suspend and resume that production lazily.

Iterators produce values one at a time, and generator functions use yield to suspend and resume that production lazily. This is the base concept interviewers commonly test first.

Track: Python