So, how do we access all this fun with Python? Well, it's all down to a module called turtle, which has a collection of Logo-like commands, implemented as functions - plus some useful window and event management features.
The turtle module's functionality is split into a number of categories. In broad terms these are:
• turtle movement• pen control
• colour and fill settings
• special shapes
• window management
• event handling
Installation
The turtle module is already installed with Python 3, but not always there with Python 2.7. To check start new a Python interactive session and enter this statement:
>>> import turtle
If you see an error message about a missing module, don't worry. Presuming you are running the standard Debian Linux image, make sure the Raspberry Pi is connected to the Internet, open a Terminal window and type the following command:
sudo apt-get install python-tk
If prompted enter the password you used to login in with, and reply y to any prompts.
Now we can write our first turtle graphics code.
A post from my Learn Python on the Raspberry Pi tutorial.