Hello, Turtle! Move and Turn


Welcome to Python for Kids! This summer you’re going to teach a computer to draw, make patterns, and create art — using a real programming language called Python, the same one used by scientists, game makers, and people who build your favorite apps. Nothing to install. Every bit of code runs right here on the page: you press a button, and it happens.

Let’s draw something in the next two minutes.

Meet the turtle

Picture a tiny robot turtle in the middle of the screen, holding a pen. When you tell it to move, it drags the pen and leaves a line behind it. That’s how we draw: you give the turtle instructions, one line at a time, and it does exactly what you say, in order.

Here are your first instructions. Press ▶ Run:

 

You just ran a real Python program! Here’s what the three lines say:

  • import turtle — “I’d like to use the turtle.” (You do this once, at the top.)
  • t = turtle.Turtle() — “Give me a turtle, and let me call it t.”
  • t.forward(100) — “Turtle, walk forward 100 steps.” That’s the line you saw drawn.

Try it 🎯

  1. Change 100 to 200 and Run. Longer line!
  2. Change it to 30. Tiny line.
  3. Try a big number like 350.

You’re steering the turtle. Bigger number, longer walk.

Going backward

The turtle can also walk backward with t.backward(...). The two move-lines run top to bottom, one after the other:

 

Forward, then back halfway along its own line. This is the most important idea in programming: the computer does your instructions in order, one at a time.

Predict it 🔮

Before you Run the next one, guess: where does the turtle end up after this? Then Run and check.

 

(It walks out 150 and comes all the way back to where it started, right where the turtle began.)

Turning corners

A turtle that only goes straight is boring. It can also turn:

  • t.right(90) — turn 90 to the right.
  • t.left(90) — turn 90 to the left.

The number is how far to turn. For now, just know that 90 is a square corner (a quarter turn). Walk, turn, walk:

 

See how the second line goes down? The turtle turned first, then walked in the new direction. You drew an “L”!

Try it 🎯

  1. Change right(90) to left(90). Which way does it bend now?
  2. Change 90 to 45. A gentler corner.
  3. Add a third move: another t.right(90) and t.forward(100). Where does it go?

Draw a path

Now you can send the turtle on a journey. Run this staircase, then make it longer:

 

Your mission 🚀

Draw a square all by yourself. A square is: forward, turn, forward, turn — four times around, turning 90 at each corner. Finish the one below (two sides are done):

 

(You need two more t.forward(100) and two more t.right(90). When the box closes, you did it!)

Fix the bug 🐞

This is supposed to draw a square, but something’s wrong — it doesn’t close up. Can you spot and fix it? (Hint: look closely at one of the turns.)

 

(The third turn is a left instead of a right. Change it to t.right(90) and the square closes.)

What you learned today

  • A program is a list of instructions the computer follows in order.
  • forward and backward move the turtle; right and left turn it.
  • Put moves and turns together to draw paths — and even a square.
  • Tinkering with the numbers is the whole game. You can’t break anything!

Next time, we’ll dig into turning properly (what those degree numbers really mean), and you’ll learn the one rule that lets you draw a triangle, a pentagon, a hexagon, any shape. See you then! 🐢

Comments