Level 2

If Then

Level 2 · Chapter 9

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 3–5

Use events, loops and if-then in one program.

Code 1B-AP-10Read the official text

Also practised: 1B-AP-15

Common Core State Standards for Mathematics

Number & Operations in Base Ten · Grade 2

Read numbers as hundreds, tens and ones.

Code 2.NBT.A.4Read the official text

The short lines are our own words. We matched this lesson to these standards ourselves; the standards' owners have not reviewed or endorsed this course.

Common Core State Standards © 2010 National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

Today you will run code only when a condition is true.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 1B
✦ CSTA 1B-AP-10 · CSTA 1B-AP-15 · ISTE 1.5.a · Standards
🎯 I canrun code only when a condition is true
🧩 New blocks1 block
📝 New words8 words
⏱ Lesson time~35 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students may put the say block outside the if block — the cat speaks every frame, not only at the edge.
  • Students may leave the diamond <> slot empty — the if block never triggers without a condition inside.

🎯 Differentiation

🐢 Struggling: Print a two-column chart: TRUE → code runs | FALSE → code skips. Have the student match each frame of the sequence to TRUE or FALSE before building.

🚀 Advanced: Challenge them to add a second if block that checks touching Sprite2 from Ch8 — combine both conditions in the same forever loop.

💡 During the lesson

  • Warm-UpPoint to Frame 2 ("checking"). Say: "Every single frame the cat asks: Am I at the edge?" Reinforce that the check happens continuously inside the forever loop — not just once. Then act it out: stand at the door, press an imaginary button, open the door. Say: "IF I press → THEN the door opens. IF I do NOT press → THEN nothing happens." Ask students to think of other IF/THEN rules from daily life.
  • Try ItExperiment 1 is the baseline. Experiment 2 adds one block inside the if — the cat now reacts in two ways at the edge. Experiment 3 puts say outside the if — the cat says "Edge!" every time, not only at the edge. This contrast shows what the if block is FOR: it gates the code by a condition.
  • PlanDo the first box together, then let students pick and watch both stages. Ask students: "Which box is the IF moment?" (The third box.) "What is the condition?" (Touching edge.) Verbalizing this before building reinforces the concept.
  • BuildWatch that students snap the sensing block INTO the diamond slot — it should lock in with a click. If a student drops it outside the slot, show them how to drag it directly onto the <> space. Walk the room during steps 3-4.