Programming Easy

Python: List Comprehensions

List comprehensions are one of Python's most beloved features — a concise syntax for building lists that is both readable and efficient. This quiz tests your understanding of the syntax, filtering with conditions, nested comprehensions, and when to use a generator instead.

Questions cover basic list comprehensions, conditional filtering (if clause), transformations, nested comprehensions for 2D data, dictionary and set comprehensions, and generator expressions. These patterns appear constantly in professional Python code.

Once list comprehensions click, your Python code becomes dramatically more readable and Pythonic. This quiz helps you verify that click has happened.

Start quiz → Opens in a new tab on Cletica

What This Quiz Covers

  • Basic syntax: [expression for item in iterable]
  • Filtering: [x for x in list if condition]
  • Transformation: applying a function or expression to each element
  • Nested list comprehensions: flattening 2D lists
  • Dictionary comprehensions: {k: v for k, v in iterable}
  • Set comprehensions: {x for x in iterable}
  • Generator expressions: (x for x in iterable) and when to prefer them
Sample questions3 of 10 shown
Q1
What does [x**2 for x in range(5)] produce?
Q2
How do you filter only even numbers from a list using a list comprehension?
Q3
What is the key difference between a list comprehension and a generator expression?
Answer all 10 questions on Cletica →

Cletica

Want to create your own quiz?

Build surveys and quizzes, share with anyone, collect responses — free to start.

Try Cletica for free →