Sign InNuggetsTutorials CodePadCheatsheet

Turtle Graphics

Although ASCII art is pretty cool, it is tedious to draw more complicated pictures using print( ).

Python has a special module called turtle that we can use to draw pictures on a screen. A module in Python is a way of providing useful code to be used by another program. Imagine a robotic turtle starting at (0, 0) in the x-y plane. You can instruct it to draw lines wherever it goes. Computer graphics is the use of a computer to produce images. Turtle graphics is a computer graphics module in Python.

Here's an example. Play with it and try a few different variations to see what happens.

import turtle crush = turtle.Turtle() for steps in range(100): crush.forward(steps) crush.right(45)
© CS Wonders·Home·About·Contact·Classes·Gallery·Glossary·Fun Facts