Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What two methods must an object implement to be considered an iterator?
Think about what allows us to navigate through elements one by one.
What does the StopIteration exception signify in an iterator?
It's a signal that you have reached the end.
Which method must be implemented to create an iterator?
Consider which method gives you access to the iterator.
True or False: An iterator can only be used once.
Remember how iterators maintain their state.
Create a custom iterator that generates prime numbers up to a given limit.
Consider how prime numbers are generated and stored.
Write a generator that returns the first N numbers of the Fibonacci sequence, where N is provided by the user.
Remember the Fibonacci rule of adding the last two numbers to get the next one.
4 more questions in this section. Enroll free to practise them all.
Enroll free