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

Block coding lesson 13: If there is a wall

UK version. UK school years and UK spelling. · US version of this lesson

An if block checks something – such as "wall ahead" – and only runs the blocks inside it when that is true. A complete 40-minute block coding lesson (Years 5–6, KS2), 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
Year
Years 5–6, KS2 (ages 9–11)
You need
A computer or tablet, squared paper and a pencil
Marked
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 marked straight away.

  1. Before the screen: Play "if it is raining, take an umbrella": make up three if rules for getting dressed.
  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: “Why might a program need to make a choice?”
  5. Later that day or the next day: the homework (20 minutes), then a practice test.

Watch out for

  • Thinking the blocks inside an if always run. They run only when the condition is true at that moment.
  • Thinking the if checks again later by itself. It checks once, each time the program reaches it – put it in a repeat to keep checking.

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

We are learning to use an if block to make a choice.

Success looks like

  • I can use an if block to make a choice.
  • I can say what happens when the condition is true and when it is false.
  • I can write one program that works on different mazes.

Key words

if · condition · true · false · selection

The big ideas (for the adult)

An if block checks something – such as "wall ahead" – and only runs the blocks inside it when that is true.

A program with if blocks can work on many mazes, not just one. We test it on mazes the pupil has not seen.

A worked example

repeat 3 times
    if wall ahead
        turn left
    end
    move forward 1
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 minMarked by Classfern
Teach8 minWatch, talk and try
Worked example and try it8 minMarked by Classfern
Practice14 minMarked by Classfern
Plenary5 minMarked 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 marked instantly. Away from the screen: play "if it is raining, take an umbrella": make up three if rules for getting dressed.

Practice tests

All computing practice tests · All 18 block coding lessons

Curriculum

National curriculum in England, computing, key stage 2: pupils should be taught to use sequence, selection, and repetition in programs; work with variables and various forms of input and output; and to use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs.

Contains public sector information licensed under the Open Government Licence v3.0.

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