Sample lesson · grade 6
Algorithms and loops
See what a complete CodeSmarter lesson looks like, from introduction to knowledge check.
What is a loop and why do we use it?
A loop is an instruction that repeats the same part of a program many times. Instead of writing five identical lines, you describe one action and tell the computer how many times to run it.
On every repetition the program checks a condition: if it is true, it runs the instructions inside the loop and goes back to the start. When the condition is no longer true, the loop ends.
One loop, five lines of output
for i in range(1, 6):
print(i)Output
- range(1, 6)
- The range starts at 1 and stops before 6. The last number is not included.
- i
- The loop counter. Each repetition gives it a new value: 1, 2, 3, 4, 5.
- print(i)
- The instruction inside the loop. It runs once per repetition.
Your turn
Change the code so the program prints the numbers from 1 to 10.
Console
Run the code to see the output.
The student is never left alone with a mistake

Alex
Look at the second argument of range(). What value makes the loop reach 10?
One question to finish
How many times does for i in range(1, 5) run?
After this lesson the student can:
- explain what a loop is
- recognise when a loop is the right tool
- write a simple for loop
- fix a basic mistake in a loop
That is one lesson. Now see all of CodeSmarter.
In the demo we walk through the grade 4–8 curriculum, the teacher panel and school rollout.