0% found this document useful (0 votes)
110 views

L5 Lesson plan – Programming essentials in Scratch_ part I – Y7

Uploaded by

22pereirag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

L5 Lesson plan – Programming essentials in Scratch_ part I – Y7

Uploaded by

22pereirag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Year 7 – Programming essentials in Scratch: part I Lesson plan

Lesson 5 – Count-controlled iteration

Lesson 5: Count-controlled iteration


Introduction
In this lesson learners will be introduced to the concept of iteration. Specifically in this
lesson, the examples will be focused on count-controlled iteration. The learners will be
given an inelegant program and be asked to spot patterns and repetition. They will be
taken through a live coding demonstration to take their inefficient program and add
iteration to make it more efficient. Learners will then use pair programming to create a
Scratch version of the nursery rhyme Ten Green Bottles, using count-controlled iteration.
Finally, learners will be introduced to the concept of debugging and they will be given a
program to debug by tracing the value of the variables.

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:

Page 1 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

Difficulty in understanding implicit changes to for loop control variables.

You will need:

● Access to Scratch 3: either via the web (https://scratch.mit.edu/) or offline


(https://scratch.mit.edu/download/). Check that your school filters do not block
any part of this website.
○ Counting cat: Learner starter program (ncce.io/CountingCat)
○ Counting cat: Teacher version (ncce.io/alp1-5-a2-c)
○ Ten green bottles: Learner starter program (ncce.io/10GreenBottles)
○ Ten green bottles: Completed version (ncce.io/alp1-5-a3-c)
○ Debugging plenary: Times table program (ncce.io/TimesTableDebugging)
● Slide deck
● AS Worksheet - Spot the pattern
● A2 Resource: Live coding.mpg
● AP Worksheet - Debugging
● AP Resource: Escape the maze explorer task
● L5 Homework

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.

*Timings are rough guides

Page 2 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

Starter Spot the pattern


activity
(Slide 2) Have slide 2 on the board and distribute the ‘Spot the pattern’ activity sheet
as the learners enter the classroom. Ask them to write down their answer
5 mins before discussing it with the person next to them.

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.

Activity 1 Introduction to iteration


(Slides 4–6)
Define iteration to the learners as it is on the slide: “Iteration in computing is
5 mins the process of repeatedly executing instructions”.

Discuss with learners that, historically, computers have been developed to


make our lives easier. One way in which they are able to do this is to
complete repetitive tasks previously done by humans at a much faster
speed. For example, a school report sent home to parents: the computer is
able to take the grades from all of the subjects and compile this relevant
data into a letter for the parents. It is able to do this for every learner in the
school at the click of a button.

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.

Count-controlled and condition-controlled

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”.

Activity 2 Live coding


(Slide 7)
In this activity you will do some live coding and demonstrate how to adapt
15 mins the program the learners looked at for the ‘Spot the pattern’ activity in
order to make the program more elegant. You can see an overview of the
steps in the A2 Resource: Live coding video which is aimed towards
teachers; the learners should follow your demonstration using the steps
below.

Page 3 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

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:

Step 2: Add count-controlled iteration

● 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?

Give learners a minute or two to replicate the changes in their own


program.

Step 3: Variables

● Ask the learners to think back to their original code:


○ What was the part of the Say block that changed?
○ Which part stayed the same?
○ What was the pattern?
○ It was the number that has changed, whereas the number of
seconds remained at one second each time. The pattern was
that it increased by one each time.

● 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.

Page 4 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

Give the learners another minute to complete this, but also ask them to run
their program.

Step 4: Incrementing the variable

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.

Demonstrate the program running. It should now count from 0 to 9.

● Ask, did it repeat ten times?


○ It does, even though it only reaches 9. This is because it
started at 0.
● Ask why they think that the number starts at 0?
○ It’s because the program hasn’t been given a starting value
and Scratch is programmed to make the assumption that it
should be 0 unless told otherwise.
● Demonstrate going to the variable menu and picking out the Set
‘number’ to 0 block.
● Deliberate mistake: Place this block inside the loop, before the Say
number for ‘1’ seconds. If the learners don’t spot the mistake, run
the program and they will see that the cat will only say “1” again. We
know that this means there is a bug in the code. Once this activity is
complete, they will be introduced to the terms: bug and debugging.
● Correct the mistake and place the block after When green flag is
clicked but before the count-controlled loop.

Allow another two or three minutes for learners to complete this.

Page 5 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

Explorer tasks:

● Edit the code so that it counts down from 10 to 1


● Edit the code so that it counts to 50, starting at 5 and incrementing 5
each iteration

Activity 3 Ten green bottles: pair programming


(Slide 8)
Explain to the learners that their next task involves pair programming.
15 mins Remind them of the roles of the driver and the navigator. Inform the
learners that they will swap roles every five minutes.

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:

Ten green bottles: Starter program (ncce.io/10GreenBottles)


Ten green bottles: Completed version (ncce.io/10GreenBottlesComplete)

1. Solve the Parson’s Problem by placing the blocks in an order that


plays the first verse to Ten Green Bottles
2. Modify the program so that it plays the full nursery rhyme in the
most efficient way possible

Explorer activities

1. When number of green bottles reaches one, change the program to


switch ‘bottles’ to the singular (“one green bottle” instead of “one
green bottles”). Learners might achieve this by changing the number
of times the loop iterates and adding new blocks outside of the loop.
Alternatively this can be achieved by adding a counter variable and
using selection to check when the value of the variable is equal to
one.
2. Ask the learners to research the nursery rhyme Five Little Ducks
(https://en.wikipedia.org/wiki/Five_Little_Ducks).
a. Now build a Scratch program to say the lyrics to the nursery
rhyme in the most efficient way possible, by using count-
controlled iteration and a variable.

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

Page 6 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

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.

In the context of programming, a bug is an error in the logic of their code


that makes the program behave unexpectedly. This might be not producing
the right output or the application closing unexpectedly. Learners might be
able to relate to this with apps they have on a mobile device. Often when
apps are updated, the update description says ‘bug fixes’.
Introduce ‘debugging’ as the process of identifying and attempting to fix an
error.

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.

Next time Review the summary slide.


(Slide 11)

5 mins

Page 7 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Lesson plan
Lesson 5 – Count-controlled iteration

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.

Page 8 Last updated: 08/03/2021

You might also like