Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 5)
5.
What is the primary advantage of using generators?
Generators consume less memory compared to lists
Generators can only produce infinite sequences
Generators allow for random access of elements
Generators are faster than regular functions
Answer: Option
Explanation:
Generators are memory-efficient as they produce values on-the-fly and do not store the entire sequence in memory. This makes them suitable for handling large datasets or infinite sequences without using excessive memory.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.