Block coding lesson 17: Changing a variable (and a first look at Python)
UK version. UK school years and UK spelling. · US version of this lesson
change size by 1 adds 1 to the number in the box. Inside a repeat, the variable grows each time round – each line is longer than the last, which draws a spiral. A complete 40-minute block coding lesson (Years 5–6, KS2), from Unit 6: Variables. 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.
- Before the screen: Climb the stairs saying the step number each time: "change step by 1".
- Press Start the lesson below and watch the worked examples together. Press Run and say what each block does before Myrtle does it.
- 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.
- Finish with the talk question: “How does changing a variable make a spiral?”
- Later that day or the next day: the homework (20 minutes), then a practice test.
Watch out for
- Thinking
change size by 1sets size to 1. It adds 1 to what is already there. - Forgetting the change runs every time round the loop. Write the value down after each time round.
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 change a variable while the program runs.
Success looks like
- I can change a variable while the program runs.
- I can predict what a variable holds at the end.
- I can match blocks to the same program in Python.
Key words
change · increase · spiral · Python
The big ideas (for the adult)
change size by 1 adds 1 to the number in the box. Inside a repeat, the variable grows each time round – each line is longer than the last, which draws a spiral.
The same program can be typed in Python: forward(size), right(90), size = size + 1. Spelling trap: Python always writes color, the American spelling, even on a UK computer.
A worked example
set size to 1
repeat 5 times
move forward size
turn left 90°
change size by 1
endPress Start the lesson to watch the turtle run it.
The lesson, step by step
| Part | Time | How it is checked |
|---|---|---|
| Starter | 5 min | Marked by Classfern |
| Teach | 8 min | Watch, talk and try |
| Worked example and try it | 8 min | Marked by Classfern |
| Practice | 14 min | Marked by Classfern |
| Plenary | 5 min | Marked 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: climb the stairs saying the step number each time: "change step by 1".
Practice tests
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. Python is a registered trademark of the Python Software Foundation; Classfern is not affiliated with or endorsed by it.