Loops and Repetition
Loops and Repetition
Deze slide heeft geen instructies
Learning goal
I can use loops to repeat instructions and make a program shorter and clearer.
Deze slide heeft geen instructies
What words come to mind when you hear looping in coding?
Use this to activate prior knowledge after the learning goal. Expect words such as repeat, again, pattern, code, move, times, stop. Pick a few responses and link them to repetition in programming.
Lesson introduction
This KS2 computing lesson explores Loops and Repetition in Programming. Pupils use count-controlled and condition-controlled loops to make code shorter, clearer and more efficient. It is suitable for classroom teaching, independent practice or a clear recap of the topic.
Deze slide heeft geen instructies
What does repeat mean?
To repeat means to do something again
In programming, a computer can repeat instructions for us
This saves time when the same step happens many times
Open from familiar routines such as clapping, brushing teeth, or taking steps. Link everyday repetition to repeated instructions in code.
Why programmers use loops
Fewer instructions to type
Code is easier to read
Repeated actions stay the same each time
Programs can be more efficient
Stress that loops are helpful when the same instruction or group of instructions happens more than once.
Without a loop
A sprite moving forward 10 steps five times might be written as:
move 10
move 10
move 10
move 10
move 10
Use this as the 'before' example. Pupils should notice the repeated command quickly.
With a loop
The same program can be written as:
repeat 5 times
move 10
One loop does the same job with less code.
Point out that the action stays the same, but the code becomes shorter and clearer.
Why do programmers use loops?
To add more bugs
To make code shorter
To stop all movement
To change the keyboard
Checks the first teaching block on repetition, efficiency and clearer code. The correct answer matches the core idea from slides 3 to 6.
Finish the loop idea
In programming, a loop repeats instructions. This saves time and can make code shorter and clearer.
A simple vocabulary check using load-bearing words already taught: loop, time, clearer.
How does a loop help in the move 10 example?
Expected answer elements: pupils should say that repeated lines such as move 10 again and again can be replaced by one repeat instruction; loops reduce typing and make code easier to read.
What is a count-controlled loop?
A count-controlled loop repeats instructions a set number of times. The programmer knows the number before the loop starts.
Examples: repeat 4 times, repeat 10 times, repeat 100 times.
Keep the phrase 'set number of times' consistent throughout the lesson.
Count-controlled loop example
To draw a square, a turtle could:
move forward
turn 90°
These two instructions repeat 4 times.
This is a strong visual example because each side of the square uses the same pair of instructions.
Spot the repeated pattern
In a loop, we look for the part that happens again and again.
For the square pattern, the repeated pattern is:
move forward
turn 90°
The number of repeats is 4.
A common mistake is choosing only one command as the pattern when two commands repeat together.
When count-controlled loops help most
Drawing shapes with equal sides
Moving a character the same way many times
Repeating a sound or animation
Counting through a fixed set of actions
Deze slide heeft geen instructies
Which is the repeated pattern for drawing a square?
move forward, turn 90°
move forward only
turn 90° only
repeat 90 times
Targets the common misconception named on slide 9: the pattern is the pair of instructions, not just one command.
Count-controlled loops
A count-controlled loop repeats a set number of times. To draw a square, the turtle uses move forward and turn 90°. This pattern repeats 4 times.
Application remains close to the taught square example so it stays accessible for KS2 pupils.
Which job suits a count-controlled loop best?
Clap 6 times
Move until water
Wait for a win
Keep going while score changes
Deze slide heeft geen instructies
What is a condition-controlled loop?
A condition-controlled loop keeps repeating until something changes.
The loop does not stop after a set number. It stops when a condition is met, such as until touching the edge or while the score is below 10.
For KS2, keep the focus on the idea of 'keeps going until a rule says stop'.
Condition-controlled loop example
A sprite could:
move 5 steps
repeat until touching the wall
The sprite keeps moving and only stops when it reaches the wall.
Contrast this with a count-controlled loop: here we do not decide the number of repeats at the start.
Count-controlled or condition-controlled?
Count-controlled loop: repeat a set number of times
Condition-controlled loop: repeat until a condition is true
Both repeat instructions, but they stop in different ways.
This comparison slide is a key turning point in the lesson. Keep the distinction crisp and simple.
Be careful with condition-controlled loops
If the condition is never met, the loop may not stop.
Example:
repeat until touching the wall
but the sprite turns away from the wall
The program can keep going for too long.
This introduces debugging thinking without going beyond KS2. Avoid technical terms like 'infinite loop' unless you want to mention it briefly aloud.
Checking loop code
When a loop does not work, check:
What instructions are repeating?
How should the loop stop?
Is the number of repeats correct?
Can the condition ever be met?
Frame debugging as careful checking, not failure. This supports pupils who find programming frustrating.
Choosing the right loop
Use a count-controlled loop when you know the exact number of repeats.
Use a condition-controlled loop when the program should stop because of what happens in the program.
Examples to mention: 'jump 8 times' versus 'keep moving until the treasure is found'.
How does a condition-controlled loop stop?
After one turn
When a condition is met
After ten repeats
When code is longer
Checks the key distinction from slides 11 to 16: condition-controlled loops stop because of a rule, not a fixed count.
Stopping rules
A condition-controlled loop keeps repeating until something changes. It does not stop after a set number. If the condition can never be met, the program may keep going too long.
Reinforces both the stopping rule and the caution about loops that may not stop.
When would you choose each type of loop?
Expected answer elements: use a count-controlled loop when the number is known exactly beforehand; use a condition-controlled loop when the loop should stop because something happens in the program, such as touching an object or reaching a score.
Examples of each loop
Move until touching water
Keep asking until the answer is correct
Continue while lives are above 0
Count-controlled loop
Clap 6 times
Draw a triangle 3 times
Flash a light 10 times
Condition-controlled loop
Use the examples to reinforce the stopping rule in each case.
Writing better programs with loops
Loops help programmers make code:
shorter
clearer
easier to change
Instead of editing many repeated lines, a programmer can change the instructions inside one loop.
This resolves the central question: loops improve programs because they organise repetition efficiently.
Which loop fits ‘keep asking until the answer is correct’?
Count-controlled
Condition-controlled
One-time command
Debug loop
This acts as the application task by asking pupils to choose the correct loop for a real example from the lesson's final block.
Better programs with loops
Loops help make code shorter, clearer and easier to change. A programmer can edit one loop instead of many repeated lines.
Summarises the central lesson message from slides 17 and 18.
What is one thing you learned about loops today?
Reflection only. Invite short responses about the main idea learned, such as using loops to repeat instructions, choosing between count-controlled and condition-controlled loops, or making code shorter and clearer.
What helped you understand loops best?
Reflection only. Useful for differentiation and future planning: pupils may mention examples, diagrams, square patterns, comparing loop types, or checking how loops stop.
How confident do you feel about choosing the right loop now?
Deze slide heeft geen instructies
Glossary
loop - a set of instructions that repeats
repeat - to do something again
count-controlled loop - a loop that repeats a set number of times
condition-controlled loop - a loop that repeats until a condition is met
condition - a rule that tells the program when something is true or false
debug - to find and fix mistakes in code
efficient - working well without unnecessary steps
Deze slide heeft geen instructies