▶ TrainingGet Pro
All tools & lessonsAll toolsAllGet the appApp
Learning departments Music, Math, Cookery, Programming and Art are open – explore →

Block coding lesson 14: If … else

US version. US grades and US spelling. · UK version of this lesson

if … else chooses between two sets of blocks: one when the condition is true, the other when it is false. Exactly one set runs. A complete 40-minute block coding lesson (Grades 4–5), from Unit 5: Choices: if, else and repeat until. Myrtle the Turtle runs right here in your browser – nothing to install.

Time
40 minutes + 20 min homework
Grade
Grades 4–5 (ages 9–11)
You need
A computer or tablet, squared paper and a pencil
Graded
Instantly, with explanations

For parents: how to use this lesson

You don't need to know anything about coding. The lesson explains each step on screen, the way Mr Babbage, our Head of Computing, likes it: watch Myrtle first, then have a go. Programs are made from blocks – no typing – and every answer is graded straight away.

  1. Before the screen: Sort the family's shoes: if it is a trainer, put it here, else put it there.
  2. Press Start the lesson below and watch the worked examples together. Press Run and say what each block does before Myrtle does it.
  3. Let your child do the practice on their own. When Myrtle goes the wrong way, that's a clue, not a failure – press Run again and watch which block it is on.
  4. Finish with the talk question: “What is the difference between if and if … else?”
  5. Later that day or the next day: the homework (20 minutes), then a practice test.

Watch out for

  • Thinking both parts run. Only one part runs each time – never both.
  • Mixing up which part is for true. The first part is for "yes, it is true"; the else part is for "no".

Miss Lovelace's tip for home: ask your child to be Myrtle. Read out the blocks and let them walk it on the floor. If they can act it out, they understand it.

What your child will learn

Learning goal: use if … else.

Success looks like

  • I can use if … else.
  • I can say which blocks run for each answer to the condition.
  • I can follow a path that bends.

Key words

if · else · otherwise · decision

The big ideas (for the adult)

if … else chooses between two sets of blocks: one when the condition is true, the other when it is false. Exactly one set runs.

Inside a repeat, if … else lets Myrtle decide at every step: move on if the path is clear, otherwise turn.

A worked example

repeat 5 times
    if path ahead is clear
        move forward 1
    else
        turn left
    end
end

Press Start the lesson to watch the turtle run it.

The lesson, step by step

40 minutes in 5 parts
PartTimeHow it is checked
Starter5 minGraded by Classfern
Teach8 minWatch, talk and try
Worked example and try it8 minGraded by Classfern
Practice14 minGraded by Classfern
Wrap up5 minGraded by Classfern + self-check

The lesson

It runs here on the page. No sign-up and no names – progress is kept only in this browser. Each visit picks a new mix of questions.

Homework

20 minutes: 6 questions – work out what Myrtle does, then build or fix a program – and a short reflection. New questions every time, all graded instantly. Away from the screen: sort the family's shoes: if it is a trainer, put it here, else put it there.

Practice tests

All computer science practice tests · All 18 block coding lessons

Curriculum

CSTA K–12 Computer Science Standards (2017), grades 3–5: 1B-AP-10 – Build programs with sequences, events, loops and conditionals; 1B-AP-08 – Compare and refine several algorithms for one task and pick the best.

The standard codes are CSTA's; the descriptions are our own words.

Our lessons, blocks and questions are our own. They are not written or endorsed by any government department, testing agency or exam board.