In Python, iterators are objects used to iterate over iterable collections like lists, tuples, and dictionaries. This quiz will test your understanding of iterator behavior, __iter__(), __next__(), and real-world usage patterns in Python.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which function is used to get an iterator from an iterable?
Correct
Incorrect
Question 3 of 15
3. Question
What does the next() function do?
Correct
Incorrect
Question 4 of 15
4. Question
Which of the following is iterable but not an iterator?
Correct
Incorrect
Question 5 of 15
5. Question
What happens when next() is called after the iterator is exhausted?
Correct
Incorrect
Question 6 of 15
6. Question
What is the output of this code?
it = iter([10, 20]) print(next(it)) print(next(it))
Correct
Incorrect
Question 7 of 15
7. Question
Which of these makes a custom object iterable?
Correct
Incorrect
Question 8 of 15
8. Question
Can a Python for loop run without __next__()?
Correct
Incorrect
Question 9 of 15
9. Question
What is the use of StopIteration in custom iterators?
Correct
Incorrect
Question 10 of 15
10. Question
What does this code do?
iter(5)
Correct
Incorrect
Question 11 of 15
11. Question
Which statement is true about iterators in Python?
Correct
Incorrect
Question 12 of 15
12. Question
What does the following code print?
nums = [1, 2, 3] it = iter(nums) for i in it: print(i) for i in it: print(i)
Correct
Incorrect
Question 13 of 15
13. Question
How do you make your class both iterable and iterator?
Correct
Incorrect
Question 14 of 15
14. Question
Which of these is a lazy iterator?
Correct
Incorrect
Question 15 of 15
15. Question
Why are iterators memory-efficient?
Correct
Incorrect
Summary
Python iterators are fundamental to understanding how loops and generators work behind the scenes. These MCQs help you grasp the inner workings of __iter__(), __next__(), and memory efficiency in real-world iteration scenarios.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.