Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What is an iterator?
Think about what you would use to loop through a sequence.
How do you declare a generator in Python?
Remember that it pauses execution at yield.
What is the purpose of the __iter__() method in an iterator?
Think about the purpose of starting the iteration.
True or False: Generators can return multiple values without using the yield keyword.
Remember the role of `yield`.
Create a generator function that generates prime numbers indefinitely.
Be mindful of how you identify primes.
Construct a data pipeline using multiple generators that process a list of numbers, filtering out even numbers and squaring the remaining.
Each generator should yield to the next.
6 more questions in this section. Enroll free to practise them all.
Enroll free