Exercise: Python

Questions for: Generators

What is a generator?
A:
A function that generates random numbers
B:
An iterable object that allows lazy evaluation of values
C:
A built-in Python module for creating HTML documents
D:
A keyword used for dynamic memory allocation
Answer: B
In Python, a generator is a type of iterable, similar to a list or tuple, but it allows lazy evaluation of values. It generates values on-the-fly and does not store them in memory all at once, making it memory-efficient.
Ad Slot (Above Pagination)
Quiz