Topics / Loops

Loops

Repeated action, accumulating state, and stopping conditions.

Novices and models both lose track of what is true after each iteration. Tracing a tiny loop is cheaper than debugging a generated one.

Identify Terminology L1 Knowledge Atoms ~1 min

What is one pass of a loop called?

Each complete run of the indented block, once for each item in the list, is called a(n) ...?

Start activity
Match Terms to Definitions L1 Knowledge Atoms ~2 min

Match the loop vocabulary

Match each term to the definition that fits it. The code is there so you can see what each term refers to; …

Start activity
Program Tracing L2 Comprehension Relations ~3 min

Running total over three numbers

What is printed when this program finishes?

Start activity
Explain Code L2 Comprehension Blocks ~3 min

Explain this letter-counting loop

Explain in plain English what this code does. Say what repeats, what changes each time, and what the program finally shows.

Start activity
Complete the Code L3 Application Blocks ~2 min

Print 1 to 5

The program should print the numbers 1, 2, 3, 4, 5, each on its own line. Which arguments complete range(...)?

Start activity
Compare Solutions L4 Analysis Relations ~4 min

Two ways to total a list

Two AI-generated programs both try to print the total of the numbers in a list. Each is a separate program. Compare them. …

Start activity
Extend the Code L5 Synthesis Macro Structure ~5 min

From a total to an average

This program totals a list of scores. Extend it so it also prints the average score. The average should be calculated once, …

Start activity
AI Suggestion Evaluation L6 Evaluation Relations ~4 min

Will this countdown ever finish?

Requirement: count_down(n) prints n, n-1, ... 1 and then prints Liftoff. An AI generated the function below. Accept or reject it, then …

Start activity