Mini Minds Hub · Free printable
Loop the Treasure Trail: Free Printable Worksheet for Year 4
In short: Free printable Loop the Treasure Trail for Year 4 (ages 8 to 9). Read the pirate code, squash it into loops, then fix the bugs.
- ForYear 4
- StageKey Stage 2
- CostFree
- FormatPrintable PDF
Loop the Treasure Trail asks Year 4 children (ages 8 to 9) to read pirate code, squash it into repeat loops and then fix the bugs. It suits children who have met simple programming ideas and can now explain what a loop does. It needs only paper and a pencil, and page 2 gives the grown-up notes, help, a stretch idea and the answers.
Before children start, model one loop out loud. Write the repeated block out in full, then tick off each go. The usual slip is mixing up the number of goes with the number of commands. Ask children to say how many commands are in one go, and how many goes there are, before they give a total.
What is on the sheet
Children read short lines of pirate code made from commands such as F, R and L, and work out what the explorer does. They trace loops, then do the reverse by taking a long list of repeated commands and writing it as a shorter loop. Finally they hunt for bugs and fix them. The numbered questions have space to answer and lines for writing.
- Repeat 3: F F R. How many F commands does the explorer run in total?
- Write this code as a loop: F F F F F F F F
- Write this code as a loop: R R F R R F R R F
Counting commands in a loop
Repeat 5: F L L. How many L commands does the explorer run in total?
This is a different question from the sheet. It shows two ways to count commands in a loop.
Method 1: write it all out- Write the block once for every repeat: F L L, F L L, F L L, F L L, F L L.
- Count only the L commands, going block by block: 2, 4, 6, 8, 10.
- Look at one go of the loop. F L L has 2 L commands.
- The loop makes 5 goes, so work out 5 groups of 2.
- 5 × 2 = 10.
How to read and write a loop
Find the block
The commands after the colon are the block. They are the part that gets repeated. Ask children to underline the block before they do anything else.
Read the number
The number after the word Repeat says how many goes the block makes. It does not say how many commands there are altogether.
Write it out to check
If a loop feels confusing, write the block out in full for each go. Then count. This makes the hidden repeats visible.
Spot the pattern
To write a loop, look for a group of commands that appears again and again. Find the smallest group that repeats, then count how many times it appears.
Why loops matter in computing
A loop tells a computer to repeat a set of instructions. Without loops, programmers would have to type the same commands again and again. Loops make code shorter, easier to read and easier to change. They also help programmers spot patterns. If a long list of commands keeps repeating, a loop can usually replace it.
A bug is a mistake in a program. Computers do exactly what the code says, even when that is not what the programmer meant. Debugging means finding the mistake and fixing it. Good programmers expect bugs. They trace the code slowly, one command at a time, and check each result. Repetition and debugging are both part of the Key Stage 2 computing curriculum in England.
Quick facts about code
- A loop repeats a set of instructions so they do not have to be written out again and again.
- Computers follow instructions exactly as they are written, in order.
- A bug is a mistake in code. Finding and fixing bugs is called debugging.
- Programmers often trace their code by hand to see what it will do.
- Many programming languages have loops, so the idea carries from one language to another.
Skills and curriculum link
- Tracing code
- Writing repeat loops
- Debugging
- Spotting patterns
- Following instructions in order
Ideas to help you support children
- Say the block firstAsk your child to read the repeated block aloud before looking at the number. This keeps the two parts of a loop separate.
- Use a keyCheck that your child can say what each letter command means. The key on the sheet is the place to look. A wrong meaning for one letter changes the whole trail.
- Trace with a fingerMove a finger along the code one command at a time. This slows children down and helps them notice a command they would otherwise skip.
- Ask what should happenFor a bug, ask your child to say what the code is meant to do. Then trace what it actually does and look for the first place the two differ.
Key words
- CommandA single instruction, such as one step forward or one turn.
- LoopA way of making a set of commands repeat.
- RepeatTo do the same thing again. In a loop, it tells you how many goes to make.
- TraceTo follow code command by command to see what it does.
- BugA mistake in code that stops it doing what was intended.
- DebugTo find a bug in code and fix it.
How to use it
- Print both pages. Page 1 is for your child. Keep page 2 for yourself, as it has the notes and answers.
- Read the key together so your child knows what each command means.
- Work through the first question together. Ask your child to say what is in the block and how many goes it makes.
- Let your child work from the matching tasks down to the bug hunt. Talk about each choice they make.
- Check against page 2 together. Come back another day to repeat the tasks that felt tricky.
Help, stretch and game ideas
If it feels too hard
Let children act out each code on the floor. Take one step for F and a quarter turn for R or L. Walking the trail makes each command real. Start with a short loop, say each command aloud, and then try the next one.
To stretch confident children
Ask children to invent their own looping code for a treasure walk. They should write it as a loop, then swap with a partner to trace. Can the partner find where the treasure is, and spot any bugs?
Make it a game
Play Pirate Robot. One child gives loop code aloud while a partner walks it across the room. Swap roles. If the robot ends somewhere surprising, trace the code together and look for a bug.
Mistakes to watch for
Watch forA child treats the number after Repeat as the total number of commands.
Try thisAsk how many commands are in one go. Then ask how many goes there are. Write the block out in full to check.
Watch forA child counts only one go of the block and forgets the other repeats.
Try thisWrite the block out for every go and tick each one. Then count what the question asks for.
Watch forWhen writing a loop, a child picks a block that does not match the code exactly.
Try thisAsk them to write the loop out in full and compare it with the original, command by command.
Talk about it
- What does the word Repeat tell the explorer to do?
- How can you tell which commands go inside the loop?
- Why is a loop shorter than writing every command out?
- What was the first thing you did when you hunted for a bug?
- How would you check that your fixed code works?
- Where else do things repeat in real life, like a daily routine?
Take it off the page
Treasure walk
Use masking tape or chalk outside to mark a start and a treasure spot. Write loop code to get there, then walk it with a friend.
Treasure map on squares
Draw a small map on squared paper. Write loop instructions for a path across it, and let someone trace the path with a pencil.
Pattern clap
Make a short pattern of claps and stamps, then repeat it a set number of times. Say it as a loop, such as Repeat 4: clap stamp.
Who it is for
Parents
Sit beside your child for the first question, then let them lead. Ask them to explain how they traced each loop. If they get stuck, act out the code together on the floor.
Teachers
Use it as a starter or plenary around repetition in programming, or as an early finisher task. Page 2 has support and stretch ideas for mixed ability groups. It also works well as a supply or homework task.
Home educators
The sheet needs only paper and a pencil, so it fits easily into a wider computing plan. Pair it with outdoor treasure walks and everyday talk about patterns. It can be reprinted for brothers and sisters or for revision.
Where this skill fits
Before this sheet, children usually meet sequences of simple commands and learn to trace them in order. They also learn that computers need precise instructions, because a small change can send the explorer somewhere very different.
After this sheet, children can move on to writing longer programs with repeats, then to adding choices in code. Many will go on to try loops in a block based programming tool. The habit of tracing and debugging by hand carries over directly.
Keep practising
If this sheet went well, find more in our Year 5 computing worksheets and Year 5 worksheets and games, or try Safe Chatting Cards, Fake News Spotter, Loop the Pattern or Star Catcher Game Blueprint next.
Browse: Mini Minds Hub > Year 5 worksheets and games > Year 5 computing worksheets
Questions parents and teachers ask
- What age is Loop the Treasure Trail for?
It is written for Year 4, which is ages 8 to 9, in Key Stage 2. It also suits confident Year 4 children or Year 6 children who want more practice with loops and debugging.
- What will children practise?
Children practise tracing, writing and debugging simple repeat loop code. They read pirate code, work out what it does, shorten repeated commands into loops and fix mistakes.
- How do I use it?
Print one per child. Read the key together, then let children work from the matching task down to the bug hunt. Work through the first question together and check against page 2 afterwards.
- What if it feels too hard?
Let children act out each code on the floor, taking one step for F and a quarter turn for R or L. Start with a short loop and say each command aloud as you move.
- Do children need a computer?
No. It is a screen free activity that needs only paper and a pencil. Children trace and write the code by hand, which gives them time to think about what each command does.
- Can teachers use it in class?
Yes. It works as a starter, plenary, early finisher task, homework or table activity. It needs no preparation beyond printing, and page 2 has support and stretch ideas for mixed ability groups.
- Can I use it for home education?
Yes. Home educators and tutors can use it on its own or as part of a wider computing plan. It can be printed again for brothers, sisters or revision a few weeks later.
Preview the full PDF
More worksheets like this
Learn it through play: toys and games from Jaques
Made by Jaques of London, making games for families since 1795. A printable supports classroom learning and does not replace a teacher.



