🌟 Book a FREE demo class today — No credit card needed   •   Live 1-to-1 coding & maths classes for kids aged 6–16   •  🌟 Book a FREE demo class today — No credit card needed   •   Live 1-to-1 coding & maths classes for kids aged 6–16   •  🌟 Book a FREE demo class today — No credit card needed   •   Live 1-to-1 coding & maths classes for kids aged 6–16   •  🌟 Book a FREE demo class today — No credit card needed   •   Live 1-to-1 coding & maths classes for kids aged 6–16   •  
Coding Tips

How a Turtle and a Robo Mermaid Teach Real Python

Py and Cody are not decoration. Here is a loop taught as a story, the same loop as four lines of Python, and the day we drop the story on purpose.

by Coach MikeAug 16, 20266 min read
In this article
  1. The child who could recite the loop
  2. The same square, as code
  3. Where the story earns its keep
  4. The day we take the story away
  5. What you can do this week
  6. Final thought

A boy in one of my classes could tell me exactly what a for loop was. He could say the words range and iterate. He had clearly been taught well by somebody.

Then I asked him to make a robot walk in a square and he sat there for two minutes without moving.

He had the sentence and not the idea. This is the most common failure in teaching children to code, and it is almost invisible, because a child who can recite the definition looks exactly like a child who understands it right up until you ask them to build something.

Py the turtle and Cody the robo mermaid exist to close that gap. They are not there to make the slides friendlier.

The child who could recite the loop

Here is the problem with teaching a loop as a definition. A definition is a thing you store. An idea is a thing you use, and the two get filed in different places.

When we say a for loop repeats a block of code a fixed number of times, every word in that sentence is correct and none of it gives a nine-year-old anywhere to put the thought. There is no picture. There is nothing to disagree with. It goes in the same drawer as the capital of Australia.

So we do not start there. We start with somebody wanting something.

Cody wants to mark out a square patch of seabed for a garden. She cannot do it herself because she is holding the seeds. Py can walk, and Py has a pen.

Now ask the child what Py should do, and something different happens. They do not reach for a definition, because there is a problem in front of them and they can see it.

They say: walk forward. Then turn. Then walk forward. Then turn.

About three sides in, every child says a version of the same thing, and it is my favourite moment in the whole term. They get bored. "It's just the same thing four times."

That sentence is the loop. They have invented it, out loud, because repeating themselves annoyed them. The English word for is a label we attach afterwards to a thing they already found.

The same loop, as a story and as codeTwo panels side by side. On the left, an underwater scene with Cody the robo mermaid and Py the turtle, and three story beats: do it four times, swim forward, turn right. On the right, the same three beats written as Python: a for loop over a range of four, containing forward one hundred and right ninety. Dotted lines join each story beat to the line of code it becomes.THE STORYTHE CODEDo it four timesfor i in range(4):Swim forwardforward(100)Turn rightright(90)Same loop. One of them is easier to remember.
The story and the code are the same three beats, in the same order.

The same square, as code

This is the part that matters, and it is why Py is a turtle rather than, say, a dragon.

Python has a drawing system built into it called turtle, which has been used to teach children since long before any of us were involved. A turtle walks and leaves a line behind it. So when Py walks the square in the story, the code that makes it happen is not an analogy or a simplified teaching version. It is the real thing, and it runs:

Py marks out the garden
from turtle import forward, right, done

for i in range(4):
    forward(100)
    right(90)

done()

Where the story earns its keep

Change the 4 to a 5 and the shape falls open, because five sides of ninety degrees do not close. Every child tries this within a minute of being shown, and I have never had to suggest it.

Now they have a question that is genuinely theirs, which is what number does close a five-sided shape. That is the door into a real conversation about three hundred and sixty degrees, and it opened because a turtle would not do as it was told.

None of that happens if you start with the definition. The definition has no five-sided shape in it.

It works the same way in a blocks class, with the sprite playing Py's part. The child drags a repeat block around move and turn, changes the 4, and watches the shape refuse to close. Same idea, same surprise, no typing. The story is doing the work in both rooms.

They invent the loop because repeating themselves gets boring. We just tell them what it is called.

The day we take the story away

A teaching metaphor that stays too long stops being a help and becomes something the child has to unlearn, so we retire these two deliberately rather than letting them fade.

Around the point where a child is writing loops without hesitating, we stop narrating. No Py, no seabed, just the code. Some children notice and object for about a week. Then they forget the characters entirely, which is exactly the outcome we want.

You can spot the handover at home. Early on your child will explain their program by telling you a story about somebody wanting something. Later they will point at the screen and say "it does this bit four times". When the story drops out of their explanation, the idea has moved in properly and no longer needs the scaffolding.

That progression is one of the clearer signs of real understanding, and it sits alongside the others in how do I know my child is actually learning to code.

What you can do this week

You do not need turtle installed and you do not need to run anything. All three of these work at the dinner table.

The aim is to catch the difference between a child who has the words and a child who has the idea.

  • Ask your child to make you walk in a square by giving instructions out loud. Follow them far too literally.
  • When they get bored of repeating themselves, ask what they would rather say instead. That answer is a loop.
  • Ask them who Py and Cody are. If they explain the loop without mentioning either, the story has already done its job.

Final thought

The boy who could recite the loop and not build one got there in a single lesson, and not because anybody explained it better. He explained it to me, using a turtle and a patch of seabed, and then wrote the four lines without help.

That is the entire argument for the characters. Not that children need things to be cute, which is usually a low opinion of children dressed up as kindness, but that an idea needs somewhere to live before it has a name.

If your child is on the other side of this and has decided the whole thing is beyond them, my child says I'm bad at coding is the one to read next. And if they are still in blocks and you are wondering about the step across, we went through the signals in when a child is ready to move from Scratch to Python.

And if your child would rather read something written for them than for you, coding isn't dying is the one to hand over.

Or come and watch a free trial class and see whether your child invents the loop before we mention it. Most of them do. One hour, no card needed.

Keep reading

More from the blog

View all posts

Need help choosing a course? Chat with us on WhatsApp! 👋