Mini Minds Hub · Free printable
Code a Story Path: Free Printable Worksheet for Year 5
In short: Free printable Code a Story Path for Year 5 (ages 9 to 10). Read the story, write the code, then find the bug and fix it. With answers for grown-ups.
- ForYear 5
- StageKey Stage 2
- CostFree
- FormatPrintable PDF
In Code a Story Path, Year 5 children (ages 9 to 10) read a short story, write code for it, then find a bug and fix it. It suits children who have met simple algorithms and are ready to use choices and repeats, and to explain their thinking in writing.
Before anyone writes a line, ask the child to trace the muddled code with a finger, one line at a time, doing exactly what each line says, even when the result looks silly. Computers cannot guess what the writer meant. That habit makes the bug easy to spot.
What is on the sheet
Children follow a story about Mina and her path. They answer questions about how the code works, then write a line of code of their own. Next they trace a piece of muddled code and spot where the story goes wrong. They fix the problem by writing the lines in a better order. The sheet ends with a written explanation, so children say why the order matters, not only what it is. There is space to answer and lines for writing.
- How many times does Mina clap?
- Which code word starts a choice?
- Which code word makes an action happen again?
- Write the line of code that makes Mina clap 3 times.
- The stones are dry. Which action does Mina skip?
- Trace the muddled code. What goes wrong at the stream?
- Which letter is the Cross the stream line? It is in the wrong place.
- Write all five letters in the fixed order.
- Explain why the IF line must come before Cross the stream.
Ways to build the idea
Walk the path
Lay a few sheets of paper on the floor as stepping places. Let your child act out the story with a toy, moving one place for each line of code. Stop at each choice and say what the toy does.
Finger tracing
Use a finger or a pencil tip to point at each line in turn. Say aloud what the character does. Do not skip ahead, even if you can see the problem coming.
Change one thing
When your child finds a bug, ask them to change only one thing, then trace the whole code again from the top. This stops them rewriting everything and shows whether the fix works.
Why code a story?
An algorithm is a set of clear steps that solves a problem or completes a task. Stories are a good way into algorithms because children already know that events happen in an order and that characters make choices. Turning a story into code asks them to be exact. Each line must say what happens, and nothing can be left to chance.
Computing in Key Stage 2 includes using sequence, selection and repetition in programs, and using logical reasoning to find and correct errors in algorithms. Writing and fixing code on paper lets children practise those ideas without a device. They slow down, read each line carefully and explain what they find.
Skills and curriculum link
- Writing simple algorithms
- Using choices in code
- Using repeats in code
- Tracing code line by line
- Finding and fixing bugs
- Explaining reasoning
Ideas to help you explain
- Computers follow lines exactlyA computer does what the code says, not what the writer meant. If a line is missing or in an odd place, it still follows the code as written.
- Order mattersCode is read one line at a time, from the top. Changing the order of lines can change what happens, even when the lines themselves are right.
- A choice depends on a conditionA condition is something that is either true or not true. The code uses it to decide which action to follow.
- Repeats save writingInstead of writing the same instruction again and again, code can ask for it to be done more than once. Counting how many times needs care.
Key words
- AlgorithmA set of clear steps for doing a task.
- SequenceInstructions that happen one after another, in order.
- SelectionA choice in code. The computer picks what to do depending on whether something is true.
- RepetitionDoing the same instructions again. Code often uses a loop for this.
- BugA mistake in code that makes it go wrong.
- DebugTo find a bug and fix it.
How to use it
- Print both pages. Page 1 is for the child. Keep page 2 for the grown-up.
- Read the story aloud, then let children work alone. Share the fixed order on a board and talk about why the order matters.
- Work through the activity together the first time. Talk about each choice.
- Check against the notes and answers on page 2.
- Come back to it another day. Repeating a familiar activity builds confidence.
Help, stretch and game ideas
If it feels too hard
Let your child act out the story with a toy and a paper plank, so they can see each step happen. Move the toy one line at a time. Pause at each choice and ask what the toy should do and why.
To stretch confident children
Ask your child to add a new IF choice for when the owl does not hoot. They should write the new lines, decide where they go, then trace the whole code to check that the story still works.
Make it a game
At home, one person acts as the computer and follows the muddled code exactly, even when it goes wrong. The other watches for the bug and says stop when they spot it. Then swap roles.
Mistakes to watch for
Watch forThe child reads the code as they think it should work, not as it is written.
Try thisAsk them to point at each line and say what happens. Remind them that the computer only follows what is on the page.
Watch forThe child miscounts how many times an action happens.
Try thisMake a tally mark each time the action is done. Count the marks at the end and compare with the code.
Watch forThe child rewrites all the code when they find a bug.
Try thisAsk them to change only one thing, then trace from the top again. Repeat if the story still goes wrong.
Talk about it
- What does the computer do if we give it the lines in a different order?
- How did you spot the bug? What was the first clue?
- Why must code be so exact? What would a person do that a computer cannot?
- Where in real life do we make a choice that depends on something being true?
- What is a job you do every day that could be written as an algorithm?
- How could you check that your fix really works?
Take it off the page
Human robot
One person gives short, exact instructions and the other follows them literally to move across a room. Swap roles and see what happens when an instruction is vague.
Muddle and mend
Write the steps for a simple routine, such as getting ready for school, on separate strips of paper. Muddle them up, swap with someone and put them back in a sensible order.
Chalk path
Draw a path outside with chalk. Write a short code for a toy to follow along it, then test it and fix any bugs.
Who it is for
Parents
Sit beside your child for the first go, then let them lead. Ask them to explain each answer out loud. If they get stuck, act out the story with a toy before they write anything.
Teachers
Use it as a starter or plenary around a lesson on selection and repetition, or as an early finisher or supply task. It needs no preparation beyond printing. Share the fixed order on the board afterwards and discuss why it works.
Home educators
This fits neatly into a wider computing plan and needs only paper and a pencil. Pair it with unplugged activities such as human robot games. Reuse it later for brothers and sisters, or to revisit debugging a few weeks on.
Where this fits
Before this, children usually work with simple sequences of instructions and short programs, and begin to notice when something does not work as planned. They learn that order matters and that instructions must be exact.
After this, children can move on to programs with more choices and repeats, and to coding on a screen, in blocks or in text. The habits of tracing, checking and fixing carry over to any language.
Keep practising
If this sheet went well, find more in our Year 5 computing worksheets and Year 5 worksheets and games, or try Binary Bracelet Game, A Message's Big Journey, Loop the Pattern or The Dice Code Mystery next.
Browse: Mini Minds Hub > Year 5 worksheets and games > Year 5 computing worksheets
Questions parents and teachers ask
- What age is Code a Story Path for?
It is written for Year 5 (ages 9 to 10), in Key Stage 2. It also works as revision for older children, or as a stretch for confident children in Year 4.
- What will children practise?
Children practise writing, tracing and debugging simple algorithms that use IF and THEN choices and a repeat loop. They also practise explaining why the order of lines matters.
- Do children need a computer?
No. The sheet needs only paper and a pencil. Children read the story, write and trace code by hand and explain their thinking in writing, so it works well as a screen free computing activity.
- Do I need to know how to code to help?
No. Page 2 gives notes, help ideas, a stretch idea and answers. The most useful thing you can do is ask your child to explain what each line does, one line at a time.
- What if my child finds it hard?
Let them act out the story with a toy and a paper plank, one step at a time. Trace the code together with a finger, then let them try the next part alone.
- 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.
- How long does it take?
There is no set time, because children work at different speeds. You can split the sheet over two sittings, or work through it together first and let your child try alone another day.
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.



