Python turtle

Python turtle

James Boudreaux

The python turtle is used to draw by writing code inside of python. First thing is to open up thronny and a new project.

python turtle

Then in the main window type this and save it.

python turtle

When you click run a window will show up that looks like this.

python turtle

This is the turtle window. Whenever you use the turtle this is what’ll show up. First thing to know is that pat.forward(100) made it go forward 100 steps. If you add pat.right(100) it’ll go forward a hundred then right a hundred steps. That is how the python Turtle works. All directions work not just these examples. I am not sure if you can go diagonal or not but I don’t think that you can. If you don’t have thronny here is how to get it.

You can also change the color of the background by entering this before the original code. The defaults for colors are black pencil and white background.

This will change the background to “blue”. There are a bunch on different colors that you can choose from so you just have to experiment around a bit. There is more of this explained inside of the Raspberry pi official handbook that comes with most Pi’s and can be downloaded for free.