Q. Which keyword is used to define a generator function in Python?

  • (A) return
  • (B) yield
  • (C) generate
  • (D) iter
πŸ’¬ Discuss
βœ… Correct Answer: (B) yield
Explanation: The `yield` keyword turns a function into a generator, which can produce values one at a time.
Explanation by: Rati Dubey
The `yield` keyword turns a function into a generator, which can produce values one at a time.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
54
Total Visits
πŸ“½οΈ
11 mo ago
Published
πŸŽ–οΈ
Rati Dubey
Publisher
πŸ“ˆ
87%
Success Rate