HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClassesGroups

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Dashboard
  • My Content
  • Profile
  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Python Going Further
  3. /Comprehensions, Iterators and Generators

Comprehensions, Iterators and Generators

Python Programming
+ Upload a Problem
More in Python Going FurtherClasses and ObjectsInheritance and Special MethodsFiles and Data FormatsComprehensions, Iterators and GeneratorsData StructuresTesting and Debugging
11 problems
Type:
1.
Write an endless generator primes() that gives 2, 3, 5, 7, 11,...
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Hard
2.
Write an endless generator squares() that gives 1, 4, 9, 16,...
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Medium
3.
Follow the generator
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Medium
4.
Used up
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Medium
5.
For each, say whether it is an iterable that is not an iterator, or an iterator, and whether it can…
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Easy
6.
A list of pairs students = [("Asha", 72), ("Ravi", 85), ("Meera", 72), ("Kabir", 90)].
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Medium
7.
Any or all?
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Easy
8.
Given names = ["Asha", "Ravi", "Meera"] and marks = [72, 85, 64], use zip and a comprehension to…
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Easy
9.
The matrix is m = [[1, 2], [3, 4], [5, 6]], three rows of two.
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Medium
10.
Write this comprehension as a plain loop, and say what it gives for numbers = [1, 2, 3, 4, 5].
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Easy
11.
Write each loop as a list comprehension.
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsStemPy LabStemPy Lab
Easy