Cheat Sheet

The tables below contain brief reminders of the instructions and operators that we use in our examples. You can find more complete descriptions of these and many others online.

Turtle Instructions



import turtle

Brings turtle into the program to use with instructions.

turtle will start in the middle of the screen, facing right (0 degrees), drawing when it moves, and using black for both drawing lines and filling regions.


Moves turtle forward by L pixels.


Moves turtle backward by L pixels.


Turns turtle clockwise by D degrees.


Turns turtle counter-clockwise by D degrees.


Moves turtle along a straight line to the point with coordinates (X,Y)


Makes turtle stop drawing as it moves.


Makes turtle draw as it moves.


Sets the color turtle uses for drawing lines to C1 and the color turtle uses for filling regions to C2.

If the instruction contains only one input (C1) then sets both colors to C1.


Marks the start of a region to be filled.


Marks the end of a region to be filled.

The region is determined as the smallest convex region containing all the points that turtle passes through in executing the instructions since the most recent turtle.begin_fill() instruction. (It is an error if turtle.end_fill() has already been executed since the most recent turtle.begin_fill() instruction or no prior turtle.begin_fill() instuction was executed.)

turtle.write(S, font=(N,Z,Y), align=A, move=B)

Writes string S at the turtle’s current position. Uses the font family named N, the point size Z`, and style Y (e.g., ‘normal’, ‘itallic’, ‘bold’); aligns S as indicated by A (one of ‘left’, ‘right’, or ‘center’); and moves the turtle if B is True; does not move the turtle if B is False.

Any of the assignments may be omitted, in which case the default values are used: font=(‘Arial’,8,’normal’), align=’left’, move=False.

Python Operators




Produces an int version of S, if S is a string denoting an integer.

For example, int(“365”) produces the int 365.


Produces a float version of S, if S is a string denoting a float.

For example float(“3.1416”) produces the float 3.1416.


Produces a str version of N.

For example, str(1/10) produces “0.1”.

a + b

If a and b are numeric, produces the number obtained by adding them together.

If a and b are strings, returns the string obtained by combining them into one, with the characters from a followed immediately by the characters from b.

Python Instructions



var = exp

Executes exp and assigns the value so produced to variable var.

Creates var if it does not already exist; otherwise, updates the value of var.

You have attempted of activities on this page