Drawing with Turtle: Shapes, Colors, and Loops You Can See

Python for Absolute Beginners · Lesson 11

What you’ll learn

1 / 14

Meet the turtle

2 / 14

Moving and turning

3 / 14

Moving and turning in code

import turtle
t = turtle.Turtle()
t.forward(100)
t.right(90)
t.forward(100)
turtle.done()

Output: an L shape, drawn on screen.

Run this in IDLE: the turtle draws a line, turns right 90 degrees, and draws a second line.

4 / 14

Three things in that snippet

5 / 14

A square, written out longhand

import turtle
t = turtle.Turtle()
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
turtle.done()

Four lines and four quarter-turns make a square — but the same two lines repeat four times.

6 / 14

The same square, with a loop

import turtle
t = turtle.Turtle()
for side in range(4):
    t.forward(100)
    t.right(90)
turtle.done()

Output: the same square, drawn on screen.

Same square, in a third of the lines: “do these two moves four times.”

7 / 14

Colors and lifting the pen

8 / 14

Colors and penup in code

import turtle
t = turtle.Turtle()
t.color("red")
for side in range(4):
    t.forward(100)
    t.right(90)
t.penup()
t.forward(150)
t.pendown()
t.color("blue")
t.circle(50)
turtle.done()

Output: a red square and a blue circle, drawn on screen.

Run in IDLE: a red square, a silent move of 150 steps, then a blue circle of radius 50.

9 / 14

Design a shape of your own

10 / 14

Hands-on exercise

11 / 14

Key takeaways

12 / 14

Take the quiz

Take the Lesson 11 quiz — 5 quick questions to check what you learned.

13 / 14

Next lesson

Lists: Many Items, Plus Indexing and Append

14 / 14

Press play on any slide and the lesson plays on by itself from there. You can still click Next or click a slide to move on.