Skip to main content

Lists and loops: storing and processing collections

programmingGrades 7-103 skills
Approved

PDF fits print binders and resource directories; HTML and embeds fit course platforms and LMS pages. LearnWorlds — Host or sell a full course around your module

Some links may be affiliate partnerships — we may earn a commission at no extra cost to you.

Total Time

47m

Skills

3

Pedagogical Notes

Start with a concrete, tangible analogy: a list is like a numbered shelf where each slot holds one item. Use a shared class example (e.g., a list of favorite foods) so all learners work with the same data throughout. Introduce prereq_001 and prereq_002 together in a single hands-on activity before moving to loops. When teaching core_001, emphasize that the loop variable is a temporary copy of each element, not the element itself—a common misconception. The accumulator pattern in core_003 should be scaffolded with a physical counting exercise (e.g., tallying on paper) before coding. For core_004, have learners predict which items will pass the filter before running the code to build conditional reasoning. The extension skill is optional and best assigned as a take-home challenge or early-finisher task; it should not be attempted if the class has not solidly mastered core_002 and core_003. Avoid introducing list slicing, nested lists, or list comprehensions in this session—they belong in a follow-up unit.

Foundational Knowledge (Assumed)

Variables and assignment — Understanding that a variable stores a single value and can be reassigned.
Basic loop syntax — Ability to write a simple counted or while loop that repeats a block of code.
Conditionals — Ability to use if/else to branch program flow based on a boolean condition.

Prerequisite Skills

Creating and indexing a list
10mDiff 1

Declare a list literal with several items and access individual elements by their zero-based index. Understand that index 0 is the first element.

Checking list length
8mDiff 1

Use the built-in length function (e.g., len()) to find how many items are in a list and explain why length matters for safe iteration.

Core Skills

Iterating a list with a for-each loop
10mDiff 1

Use a for-each (for item in list) loop to visit every element in order and perform a simple action such as printing each value.

Print every student name on a class roster one line at a time.Display each item in a shopping cart at checkout.
Modifying a list: append and remove
9mDiff 1

Add new items to the end of a list with append() and remove an item by value or index. Observe how the list changes after each operation.

Add a new song to a playlist and delete one the user dislikes.Build a to-do list app that lets users add and cross off tasks.
Accumulating a result while iterating
10mDiff 2

Initialize a counter or running total before a loop, update it inside the loop for each element, and report the final result after the loop ends.

Sum all quiz scores in a list to compute a student's total points.Count how many items in a grocery list cost more than five dollars.

Skill Dependencies

Iterating a list with a for-each loop←Creating and indexing a list
Modifying a list: append and remove←Creating and indexing a list
Accumulating a result while iterating←Iterating a list with a for-each loop
Creating and indexing a list←(no prerequisites)
Checking list length←Creating and indexing a list

Rate this module

Not yet rated