Skip to Main Content
Python for Kids, 2nd Edition
book

Python for Kids, 2nd Edition

by Jason R. Briggs
November 2022
Beginner content levelBeginner
368 pages
6h 47m
English
No Starch Press
Content preview from Python for Kids, 2nd Edition

9More Turtle Graphics

Image

Let’s return to the turtle module we began using in Chapter 4. In this chapter, we’ll learn that Python turtles can do a lot more than draw plain black lines. 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 previously used the turtle module to draw simple shapes. Let’s import the turtle module and create the Turtle object:

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

We used the following code in Chapter 4 to create a square:

>>> t.forward(50)
>>> t.left(90)
>>> t.forward(50)
>>> t.left(90)
>>> t.forward(50)
>>> t.left(90) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Cookbook, 3rd Edition

Python Cookbook, 3rd Edition

David Beazley, Brian K. Jones
High Performance Python, 2nd Edition

High Performance Python, 2nd Edition

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9781098141400