Lists and loops: storing and processing collections
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)
Prerequisite Skills
Declare a list literal with several items and access individual elements by their zero-based index. Understand that index 0 is the first element.
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
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.
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.
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.
Skill Dependencies
Rate this module
Not yet rated