L5 Lesson plan – Programming essentials in Scratch_ part I – Y7
L5 Lesson plan – Programming essentials in Scratch_ part I – Y7
Learning objectives
● Define iteration as the process of repeatedly executing instructions
● Describe the need for iteration
● Identify where count-controlled iteration can be used in a program
● Implement count-controlled iteration in a program
● Detect and correct errors in a program (debugging)
Key vocabulary
Iteration, count-controlled, condition-controlled, debugging, variables, sequencing,
subroutines
Preparation
Subject knowledge:
● You will need to be familiar with the concept of iteration and the difference
between a count-controlled loop and a condition-controlled loop
● You will need to be familiar with ‘a bug’, in relation to computing, as well as
debugging techniques
Misconceptions:
Assessment opportunities
There will be a variety of opportunities for formative assessment throughout this lesson.
They will mainly be carried out through observation and the level of support given. You
can also gain an assessment by noting how far learners progress through the ‘Ten green
bottles’ activity. Although focused on debugging, the plenary will allow you to gain an
understanding of how well learners are able to trace the values of variables and have
understood the need for a variable to increment in the count-controlled loop.
Outline plan
Please note that the slide deck labels the activities in the top right-hand corner to help
you navigate the lesson.
The program will output numbers one to ten. They may notice that the
repetition is that ten of the same block have been used with the only
difference being the number specified. There is a pattern in that the
numbers increment by one each time.
Show the example of the repetitive task of giving the punishment of writing
lines. Ask the learners to think about the instructions a teacher would need
to give to the learner for them to be able to complete the task. The aim of
this is to highlight that when you write code to instruct the computer to
iterate, you need to tell it what command you want it to carry out, as well
as how many times, or when to stop.
Keeping with the real-world example of writing out lines for a punishment,
highlight the differences between the two types of iteration. The learners
should be familiar with the term condition from previous lessons. Ask the
learners to identify the condition in the example, “write out lines until 4pm”.
Step 1
Ask the learners to open the starting point for their program: Counting cat
(ncce.io/CountingCat). Remind the learners how to remove blocks and ask
them to remove all blocks apart from the first two:
● Ask the learners how many times did they see the Say block before
they deleted the lines? The answer is ten times.
● Show the learners the control window and ask them to pick out the
block that they think they need to use. Before taking answers, you
could start dragging the Forever block into the program window to
see if they try and stop you and point out your mistake. The block
they need is the Repeat 10 block.
● Demonstrate how to place the block so that the Say ‘1’ for ‘1’
seconds fits into side the loop. Try making another mistake in the
process by placing it after the say block instead of around it.
● Run the program. The learners will see that the cat says “1”. Ask the
learners if they can identify the problem. Why did it just say “1”? How
long did it appear on the screen for? Was it more than a second?
Step 3: Variables
● Ask the learners what they would use in a program to store a value
that could change?
○ A variable
● Show the variable category and they will see that there is a variable
● Ask the learners to think about where the ‘number’ variable should
be placed in the code. They should be familiar with this from
exercises that they have done in their previous lessons.
Give the learners another minute to complete this, but also ask them to run
their program.
Ask the learners to tell you what happened when they ran the program.
They should have seen the number “0” being said for ten seconds and that
the number still does not increment.
● Visit the variables menu and pick out the Change ‘number by ‘1’
block and place it after the Say number for ‘1’ seconds block
○ You could place this block before the Say number for ‘1’
seconds block to avoid the issue of it starting with 0.
However, you will ask learners to do it a different way to
allow the program to be more flexible and usable with
different values.
Explorer tasks:
Make sure that all the learners are aware of the nursery rhyme Ten Green
Bottles. Ask the learners to open the ‘Ten green bottles’ Scratch program
and follow the tasks on slide:
Explorer activities
Plenary Debugging
(Slides 9–10)
Present the term ‘bug’ to the learners as the process of finding an error in
10–15 mins
your code and taking steps to fix the problem.
The famous example on the board is from Grace Hopper’s logbook. After
the Mark II machine malfunctioned, Grace and her team discovered that a
moth was caught in the system. This is not where the term bug originated
from in terms of malfunction (it existed before computers), but this was the
first recording of a computer error caused by a real bug. More can be read
about this here: https://en.wikipedia.org/wiki/Software_bug. Note that the
example was a bug with the hardware, whereas the term bug now refers to
errors in code or software. This is because it is assumed that hardware is
now so reliable a fault is unlikely to be caused by anything other than
errors in the code.
Display a segment of code on the board. Inform the learners that this is a
program designed to allow the user to enter a number. The program will
use the input to output the times table for that number.
Distribute the worksheet to the learners. Their task is to add two lines of
code that will output the values of the variables to the learners. Adding
output statements to output the state of a variable is a common technique
for trying to debug errors. Learners must fill out the table on their
worksheet to trace the value of the variables to help them debug the error.
They should work out that the output is the same for each iteration. The
problem is that the variable ‘multiply-by’ is not incrementing at each
iteration. Therefore the resolution is to add a new line of code inside the
loop that increments ‘multiply-by’ by ‘1’ at each iteration. If learners finish
before the allocated time, ask them to recreate the error in the Scratch
program to make sure that they were correct and then to fix the error.
Explorer activity: If learners complete the exercise before the rest of the
class, distribute the maze activity where they are required to work out
which block of code would escape the maze on the page.
5 mins
Homework Distribute the multiple choice questions for homework. There are four
multiple choice questions that will help you diagnose which misconceptions
have been addressed. Each question requires an answer as well as
justification for why they chose that answer. This will also help you gain an
understanding of what they do and don’t know and to avoid guesswork.
Resources are updated regularly — the latest version is available at: ncce.io/tcc.
This resource is licensed under the Open Government Licence, version 3. For more information on this
licence, see ncce.io/ogl.