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 how we traverse lists or tuples.
What keyword is used to define a generator?
It's a word that's also a verb for giving something.
What does an iterator implement to be considered valid?
Remember the method names start with double underscores.
True or False: Generators can be defined using the 'yield' statement.
Think about how generators work differently from normal functions.
Create an iterator class that generates Fibonacci numbers up to n. Explain how the internal state is managed.
Think about how to keep track of previous values.
Design a generator that sends and receives data, maintaining a count of received inputs until a specific input is given, then returns the total.
How do you start the generator and maintain its state with send?
5 more questions in this section. Enroll free to practise them all.
Enroll free