Week 20 — Conditionals in text¶
At a glance
| Date | Friday, January 22, 2027 |
| Unit | 3 — From Blocks to Text |
| Big idea | if statements let a program choose what to do based on a condition. |
| Goal | Students use Python if / else to make an Arcade sprite respond differently when a value changes. |
| 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¶
Conditionals are where text syntax starts to feel unforgiving: colon, indentation, and comparison operator. The concept is not new; students already used if blocks in Unit 1. Today they learn the punctuation that text Python needs.
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 variables change from button input. 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 press A several times.
energy = 0
hero = sprites.create(img("""
. 2 2 .
2 2 2 2
. 2 2 .
"""), SpriteKind.player)
def on_a_pressed():
global energy
energy = energy + 1
if energy > 3:
hero.say_text("Ready!")
else:
hero.say_text("Need more: " + str(energy))
controller.A.on_event(ControllerButtonEvent.PRESSED, on_a_pressed)
"If energy is greater than 3, say Ready. Otherwise, say Need more. The colon and the spaces tell Python what belongs inside the decision."
"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 the number 3 and the two messages.
energy = 0
hero = sprites.create(img("""
. 2 2 .
2 2 2 2
. 2 2 .
"""), SpriteKind.player)
def on_a_pressed():
global energy
energy = energy + 1
if energy > 3:
hero.say_text("Super power!")
else:
hero.say_text("Keep charging")
controller.A.on_event(ControllerButtonEvent.PRESSED, on_a_pressed)
🟡 Builder (grades 7–8): write from a template
Add a B button that resets energy to 0.
energy = 0
hero = sprites.create(img("""
. 9 9 .
9 9 9 9
. 9 9 .
"""), SpriteKind.player)
def check_energy():
if energy == 0:
hero.say_text("Empty")
else:
hero.say_text("Energy: " + str(energy))
Add A to increase, B to reset, and call check_energy().
🔴 Extender (grades 9–10): write from scratch or add features
Use elif for low, medium, high.
energy = 0
hero = sprites.create(img("""
. 5 5 .
5 5 5 5
. 5 5 .
"""), SpriteKind.player)
def report():
if energy < 3:
hero.say_text("Low")
elif energy < 6:
hero.say_text("Medium")
else:
hero.say_text("High")
Add controls to change energy and call report().
0:36–0:42 — Share-out¶
"Show one decision. Tell us the condition in English before you run it, then prove both paths work."
0:42–0:45 — Teaser + prompt¶
"Next Friday we stop repeating ourselves by hand. If a program needs to do something again and again, we use a loop."
🤔 Think About This¶
Notice one decision rule this week: if it rains, if battery is low, if the score is high enough. What is the condition?
Share-out prompt¶
"Show one decision. Tell us the condition in English before you run it, then prove both paths work."
🔌 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 if energy > 3 |
SyntaxError: expected ':' |
Add : at the end of the if line. |
No indentation after if |
IndentationError: expected an indented block after 'if' statement |
Indent the line that belongs inside the if. |
Using = instead of == |
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='? |
Use == when asking whether two values are equal. |
else indented too far |
SyntaxError: invalid syntax |
Line else: up with the matching if. |
| Only testing one branch | no error |
Change the value so both branches run. |
Vocabulary¶
- Condition — a question that is true or false
- Boolean — a true/false value
- Comparison — checking values with
>,<, or== - Indentation — spaces that show code structure
- Branch — one possible path through a decision
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?
Next week: Week 21 — Loops in text