O'Reilly logo

Python for Kids by Jason R. Briggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. More Turtle Graphics

Let’s take another look at the turtle module we began using in Chapter 4. As you’ll see in this chapter, in Python, turtles can do a lot more than just draw plain black lines. For example, you can use them to draw more advanced geometric shapes, create different colors, and even fill your shapes with color.

Starting with the Basic Square

We’ve already learned how to make the turtle draw simple shapes. Before using the turtle, we need to import the turtle module and create the Pen object:

>>> import turtle
>>> t = turtle.Pen()

Here’s the code we used to create a square in Chapter 4:

>>> t.forward(50)
>>> t.left(90)
>>> t.forward(50)
>>> t.left(90)
>>> t.forward(50)
>>> t.left(90)
>>> t.forward(50)

In Chapter 6, you learned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required