Skip to content

List Comprehensions (Introduction)Activities & Teaching Strategies

Active learning works for list comprehensions because students need to see the immediate contrast between verbose loops and concise syntax to appreciate brevity without sacrificing clarity. When students write and debug both versions side by side, they internalize the trade-offs between readability and performance, making the concept stick.

Year 9Computing4 activities15 min30 min

Learning Objectives

  1. 1Construct a list comprehension to generate a list of numbers based on a given condition.
  2. 2Compare the efficiency and readability of list comprehensions against traditional for loops for list creation.
  3. 3Modify existing list comprehensions to transform elements within a generated list.
  4. 4Analyze Python code to identify opportunities for using list comprehensions.

Want a complete lesson plan with these objectives? Generate a Mission

20 min·Pairs

Pair Programming: Square Builder

Pairs write a list comprehension to generate squares for numbers 1 to 10, then rewrite using a for loop. They run both in an IDE, compare line count and readability, and discuss advantages. Extend to cubes.

Prepare & details

Explain how list comprehensions can simplify code for creating lists.

Facilitation Tip: During Pair Programming: Square Builder, encourage pairs to swap roles after each line so both students practice writing and interpreting syntax together.

Setup: Standard classroom, flexible for group activities during class

Materials: Pre-class content (video/reading with guiding questions), Readiness check or entrance ticket, In-class application activity, Reflection journal

UnderstandApplyAnalyzeSelf-ManagementSelf-Awareness
30 min·Small Groups

Small Groups: Filter Factory

Groups receive lists of numbers and strings, then create comprehensions to filter evens or vowels. They test outputs, share code on a shared screen, and vote on clearest versions. Rotate roles for explanation.

Prepare & details

Construct a list comprehension to generate a list of squares for numbers 1 to 10.

Facilitation Tip: In Small Groups: Filter Factory, provide pre-printed starter lists and conditions on cards to reduce cognitive load and focus attention on the transformation logic.

Setup: Standard classroom, flexible for group activities during class

Materials: Pre-class content (video/reading with guiding questions), Readiness check or entrance ticket, In-class application activity, Reflection journal

UnderstandApplyAnalyzeSelf-ManagementSelf-Awareness
25 min·Individual

Individual: Comprehension Clinic

Students complete a worksheet with partial comprehensions to fix or extend, like generating multiples of 3 under 50. They self-test in Python shell and note differences from loops.

Prepare & details

Compare the readability of a list comprehension versus a traditional loop for list creation.

Facilitation Tip: For Individual: Comprehension Clinic, circulate and ask students to read their comprehensions aloud, forcing them to verbalize the flow of data through the expression, for, and if clauses.

Setup: Standard classroom, flexible for group activities during class

Materials: Pre-class content (video/reading with guiding questions), Readiness check or entrance ticket, In-class application activity, Reflection journal

UnderstandApplyAnalyzeSelf-ManagementSelf-Awareness
15 min·Whole Class

Whole Class: Readability Relay

Display loop code on board; class suggests comprehension versions in real-time. Run polls via hand signals or tools to select best, then code and verify together.

Prepare & details

Explain how list comprehensions can simplify code for creating lists.

Facilitation Tip: During Whole Class: Readability Relay, set a timer for 90 seconds per snippet so students practice scanning and refactoring under mild time pressure.

Setup: Standard classroom, flexible for group activities during class

Materials: Pre-class content (video/reading with guiding questions), Readiness check or entrance ticket, In-class application activity, Reflection journal

UnderstandApplyAnalyzeSelf-ManagementSelf-Awareness

Teaching This Topic

Teach list comprehensions by starting with a for loop students already trust, then shrink it line by line until only the comprehension remains. Avoid introducing advanced features like nested comprehensions too early, as they can obscure the basic pattern. Research shows that students grasp syntax faster when they physically rewrite loops into comprehensions, linking prior knowledge to new notation.

What to Expect

Successful learning looks like students confidently translating for loops into list comprehensions and explaining why one version may be preferable. They should also recognize when comprehensions simplify code and when loops remain clearer for complex logic.

These activities are a starting point. A full mission is the experience.

  • Complete facilitation script with teacher dialogue
  • Printable student materials, ready for class
  • Differentiation strategies for every learner
Generate a Mission

Watch Out for These Misconceptions

Common MisconceptionDuring Pair Programming: Square Builder, watch for students assuming comprehensions always outperform loops in speed.

What to Teach Instead

Use the built-in timeit module within the same file to time both versions; students will see similar speeds and focus on readability instead.

Common MisconceptionDuring Small Groups: Filter Factory, watch for students believing comprehensions alter the original list.

What to Teach Instead

Print the original list before and after the comprehension to demonstrate immutability and reassure students that transformations are safe.

Common MisconceptionDuring Individual: Comprehension Clinic, watch for students misplacing the if clause as part of the expression rather than a filter.

What to Teach Instead

Ask students to insert print(x) inside the comprehension to trace execution, revealing that the if runs first and only items passing it reach the expression.

Assessment Ideas

Exit Ticket

After Pair Programming: Square Builder, ask students to submit a reflection naming one advantage and one disadvantage of list comprehensions compared to loops.

Quick Check

During Small Groups: Filter Factory, display a for loop on the board and ask groups to write the equivalent comprehension on mini whiteboards; check for correct placement of the if clause.

Discussion Prompt

After Whole Class: Readability Relay, facilitate a brief discussion asking which snippets felt clearer as comprehensions and which felt forced, guiding students to articulate readability trade-offs.

Extensions & Scaffolding

  • Challenge: Ask students to write a nested list comprehension that flattens a 3x3 grid of numbers into a single list, then compare results with a double for loop.
  • Scaffolding: Provide partially completed comprehensions with prompts like ‘[__ for x in ___ if __]’ so students fill in the missing parts before writing from scratch.
  • Deeper exploration: Explore set and dictionary comprehensions by asking students to convert a list of word frequencies into a dictionary comprehension that inverts the mapping.

Key Vocabulary

List ComprehensionA concise way to create lists in Python, often in a single line of code, using a compact syntax.
IterableAn object in Python that can be looped over, such as a list, tuple, string, or range.
ExpressionThe operation or value that is computed for each item in the iterable to form the new list.
ConditionAn optional filter within a list comprehension that determines whether an item from the iterable should be included in the new list.

Ready to teach List Comprehensions (Introduction)?

Generate a full mission with everything you need

Generate a Mission