Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 2)
2.
How is a generator function different from a regular function?
Generator functions use the keyword yield to produce a sequence of values
Regular functions use the keyword yield for lazy evaluation
Generator functions use the keyword return to produce a sequence of values
Regular functions use the keyword yield for immediate value generation
Answer: Option
Explanation:
Generator functions in Python use the yield keyword to produce a sequence of values. When a generator function is called, it returns a generator object that can be iterated over to get values one at a time.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.