Python Turtle is based on the Logo Programming Language that has been used as a popular way of teaching children programming for many years.  

HEALTH WARNING:  Do NOT save your python file as turtle.py – this will break it!

Getting started

You will need to import the Turtle library into the script.

from turtle import *

Basic Controls

CommandExampleScratch Equiv.Description
scratchPenDown.jpg - 11/2015
Puts the pen down so when its moved it WILL draw a line.
scratchPenUp.jpg - 2019/03
Lifts the pen so it can be moved without drawing.
scratchPenColor.jpg - 2019/03
you can set the color of the pen and its fill using any of the Tkinter Colors.  For more information about colour and fills see below.
scratchPenSize.jpg - 11/2015
The width of the pen.
 Worth doing for complex shapes where you want to speed up the drawing.
 Shows the turtle if it has been hidden.  Also note that shape(“Turtle”) will change the pointer – you can pick from: arrow, turtle, circle, square, triangle, classic.
 Makes the turtle move faster, which is good for complex shapes.  Give a number between 0 and 10 where 6 is the standard speed.  0 is no animation, 1 is slowest and 10 is fastest.
 Delete the turtle’s drawings from the screen. Do not move turtle.  Use reset() if you want to move the turtle as well.

Turtle Motion

The turtle can be made to draw using the following simple commands.  It starts from 0,0, which is the centre of the window (aka origin or home position).

CommandExampleScratch Equiv.Description
scratchMove.jpg - 11/2015
Moves forward the given number of pixels.
scratchMoveBackwards.jpg - 11/2015
Scratch does not have a backwards step so we need to use negative but Turtle has backward. 
scratchLeft.jpg - 11/2015
Left turns the pointer clockwise the given number of degrees.
scratchRight.jpg - 11/2015
Right turns the pointer anti-clockwise the given number of degrees.
scratchGoTo.jpg - 11/2015
Goes to the position indicated by the x and y co-ordinate.
scratchHome.jpg - 11/2015
Puts the turtle back to the middle of the window
 Draws a circle with: a radius (e.g. 100); for an angle (e.g. 360 is full circle and 180 would be half); in the number of steps given (e.g. 8 for hexagon). 
 Draw a dot of size 1 unless you provide a bigger size e.g dot(10).

Advanced Colors

As shown above you can set the line color of the pen.  You can also use HTML colours e.g. “#33BB55” or RGB colours represented by a tuple e.g. color(100,73,45).  If you are using RGB you need to ensure that the colormode() is set to 255 e.g.


Filling Shapes

By default the turtle can draw a line or a circle with a transparent fill.  To fill an object you should first set the fillcolor.


The include begin_fill and end_fill statements to tell Python when to start filling a shape and when to stop.  This example will create a circle with a black outline and red fill.

color("black", "red")

This approach will also work with multiple lines enclosing a shape e.g. a square with a blue outline and a yellow fill.

color("blue", "yellow")
for x in range (0,4)
right(90) end_fill()

Canvas Settings

You might want to change the size or background color of the window that opens.


Random Colours

One method for picking involves making a choice from a predetermined list of colours:

from random import choices
colors = ["red", "blue", "green"]

Alternativly, you could make a random color completly:

from random import randint
randomColor = (randint(0,255),randint(0,255),randint(0,255))


  • heading() – returns the current direction of the turtle based on 0 being East.
  • towards() – gets the bearing to the coordinates given..

Fun Equations

Calculate the XY coordinates  of a circle given its radius r, origin (cx,cy) and current angle (a).  Place this in a forloop from 0 to 360 to draw a circle. x = cx + r * cos(a) y = cy + r * sin(a)

Advanced Usage

Once the library has been imported it is possible to either use the functions immediatly e.g. forward() but you can create an instance of Turtle and use it e.g.

terry = Turtle()

This approach allows for multiple drawing turtles at the same time!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.