Week 21 — Loops in text¶
At a glance
| Date | Friday, January 29, 2027 |
| Unit | 3 — From Blocks to Text |
| Big idea | Loops tell a program to repeat without copying the same lines over and over. |
| Goal | Students use a Python loop to repeat an action and modify how many times it repeats. |
| Student accounts needed | None. MakeCode Arcade runs in the browser without sign-in; Week 25 AI is teacher-demo only. |
| Prep time | 5 minutes |
Why this lesson looks the way it does¶
Loops are familiar from Unit 1, but text loops add the colon and indented body. Keep the loop body short enough that students can see where it starts and ends. Younger typists modify range(...); older students use the same pattern to create movement or repeated sprites.
The differentiation stays consistent: Starters modify working code, Builders write from a template, and Extenders write from scratch or add features. MakeCode Arcade's Python/Blocks toggle remains the safety rail for students whose typing or syntax fluency is still developing.
CSTA 2026 standards¶
| Concept area | Connection |
|---|---|
| Algorithms & Design | Students plan, test, and revise small algorithms using this week's control structure. |
| Programming | Students read and write Python syntax for the week's concept in MakeCode Arcade. |
| Data & Analysis | Students store, compare, organize, or inspect values as evidence. |
| Systems & Security | Students use a no-install, no-account browser tool and test changes before trusting them. |
| Computing & Society | Students explain program behavior clearly to another person. |
"I can…" objectives¶
By the end of today, students can say:
- I can read this week's Python pattern in plain English.
- I can modify working starter code without breaking the whole program.
- I can test my change and explain the result.
- I can use Blocks view as a scaffold, then return to Python.
Teacher prep — the 5-minute version¶
- Open https://arcade.makecode.com and switch a new project to Python.
- Paste the mini-lesson code below and run it before class.
- Put Driver/Navigator pairs on the board; swap drivers at 0:24.
- Write the debugging routine: run first, change one thing, test again.
- Keep the Starter code visible for younger students to copy or remix.
Minute-by-minute run sheet¶
0:00–0:04 — Anchor¶
"Last Friday we made decisions with
ifstatements. Today we add one new Python idea, but we keep the same rule: working code first, tiny changes, test every change."
0:04–0:12 — Mini-lesson¶
Run this and trace i aloud.
hero = sprites.create(img("""
. 7 7 .
7 7 7 7
. 7 7 .
"""), SpriteKind.player)
for i in range(5):
hero.say_text("Count " + str(i))
pause(600)
"The loop line says how many times. The indented lines say what repeats.
range(5)gives five values: 0, 1, 2, 3, 4.""Do not try to memorize every symbol. Read the pattern. Ask: what is the name, what changes, and what lines belong together?"
0:12–0:36 — Paired build¶
"Driver, you type. Navigator, you read the code and predict what should happen. If you get stuck, flip to Blocks, translate the idea, then come back to Python."
Tiered challenges¶
🟢 Starter (grades 5–6): modify working starter code
Change range(3) and the word Level.
hero = sprites.create(img("""
. 7 7 .
7 7 7 7
. 7 7 .
"""), SpriteKind.player)
for i in range(3):
hero.say_text("Level " + str(i))
pause(600)
🟡 Builder (grades 7–8): write from a template
Make the sprite move each repeat.
hero = sprites.create(img("""
. 4 4 .
4 4 4 4
. 4 4 .
"""), SpriteKind.player)
hero.set_position(20, 60)
for i in range(6):
hero.x = hero.x + 15
hero.say_text(str(i))
pause(400)
🔴 Extender (grades 9–10): write from scratch or add features
Use a loop to create several sprites.
for i in range(5):
coin = sprites.create(img("""
. 5 5 .
5 5 5 5
. 5 5 .
"""), SpriteKind.food)
coin.set_position(20 + i * 25, 50)
Add a second row or change spacing with a variable.
0:36–0:42 — Share-out¶
"Before you run it for us, tell us exactly what repeats and how many times."
0:42–0:45 — Teaser + prompt¶
"Next Friday we store more than one thing at a time. Instead of one variable for one value, we use a list."
🤔 Think About This¶
Notice one repeated pattern this week. What is the loop body? What tells it to stop?
Share-out prompt¶
"Before you run it for us, tell us exactly what repeats and how many times."
🔌 Unplugged Plan B — if the internet is down¶
| Time | Activity |
|---|---|
| 0:00–0:04 | Same anchor: last week connection and today's one new idea. |
| 0:04–0:12 | Board model of the Python pattern using paper cards for names, values, punctuation, and indented lines. |
| 0:12–0:26 | Pairs trace a paper program. One student is the human interpreter; one student is the debugger. |
| 0:26–0:36 | Pairs modify one card, trade with another pair, and run the new paper program exactly. |
| 0:36–0:42 | Share one prediction, one result, and one bug found by reading carefully. |
| 0:42–0:45 | Same teaser and Think About This. |
Common problems & fixes¶
| Problem | What students may see | Fix |
|---|---|---|
Missing colon after for |
SyntaxError: expected ':' |
Add : after for i in range(5). |
| No indentation in loop body | IndentationError: expected an indented block after 'for' statement |
Indent every line that should repeat. |
Expecting range(5) to say 1 through 5 |
no error |
Explain that it produces 0, 1, 2, 3, 4. |
| Indenting too many lines | no error |
Move lines left if they should happen after the loop. |
| Huge range slows simulator | browser feels stuck |
Stop the simulator and test with 3 first. |
Vocabulary¶
- Loop — code that repeats
- Iteration — one trip through a loop
- Loop body — the indented code that repeats
- Counter — a variable that tracks loop progress
- Range — a sequence of numbers used by a loop
Reflection — fill in after class¶
- Which students needed the Blocks bridge most?
- Which syntax error appeared most often?
- Did Driver/Navigator roles reduce typing frustration?
- What should be reviewed in the first four minutes next week?