Which of the following statements about Python generators is correct?

Options

  • A. Generators store all values in memory before iteration
  • B. Generators produce values lazily
  • C. Generators cannot be iterated using next()
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Generators produce values lazily

Detailed Explanation

Generators use lazy evaluation, producing values one at a time instead of storing the entire sequence in memory.