Python turtle module cheatsheet Cheat Sheet

A Programming › Python cheat sheet in English by NatalieMoore

Python beginner cheatsheet, playing with turtles

39,222 views 10,923 downloads 22 Mar 2015 History
4.3 avg · 1 rating

Turtle Pen

turtle.up()
Sets the pen state to be up (not drawing).
turtle.down()
Sets the pen state to be down (drawing).
turtle.co­lor­(r,g,b)
See below
turtle.co­lor(s)
Sets the color that the pen will draw until the color is changed. It takes either
 
1. three arguments, each a floating point number between 0.0 — 1.0, where the first the amount of red, the second is the amount of green, and the third is the amount of blue
 
2. a “color string” the name of a TK color (e.g., “black”, “red”, “blue”, ...)
turtle.be­gin­_fill()
See below
turtle.en­d_f­ill()
To fill a figure, use turtle.be­gin­_fill() before you start drawing the figure. Draw the figure. Then execute turtle.en­d_f­ill(). The figure drawn between the two fill commands will be filled with the present color setting.
turtle.hi­det­urtle()
See below
turtle.sh­owt­urtle()
Sets the state to hide / show the turtle. When shown, you see it as a small arrowhead pointed in the direction of the heading.
The default pen color is “black”.

Turtle other

turtle.xc­or(), turtle.ycor()
Returns the x - coordinate / y - coordinate of the current pen position.
turtle.bye()
Close the turtle drawing window

Turtle Draw

turtle.ri­ght­(de­grees)
Turns the direction that the turtle is facing right (clock­wise) by the amount indicated (in degrees).
turtle.le­ft(­deg­rees)
Turns the direction that the turtle is facing left (counter clockwise) by the amount indicated (in degrees).
turtle.fo­rwa­rd(­dis­tance)
Moves the turtle forward (in the direction the turtle is facing) the distance indicated (in pixels). Draws a line if the pen is down, not if the pen is up.
turtle.ba­ckw­ard­(di­stance)
Moves the turtle backward (in the direction opposite to how the turtle is facing) the distance indicated (in pixels). Draws a line if the pen is down, not if the pen is up.
turtle.se­the­adi­ng(­angle)
Sets the orient­ation of the turtle to angle. Here are some common directions in degrees:
 
0 (east)
 
90 (north)
 
180 (west)
 
270 (south)
turtle.go­to(x,y)
Moves the turtle to the specified coordi­nates, drawing a straight line to the destin­ation (x,y) if the pen is down, and not drawing if the pen is up.
turtle.ci­rcl­e(r­adius)
Draws a circle of the indicated radius. The turtle draws the circle tangent to the direction the turtle is facing.

Badges

Useful Cheat Sheet Good Cheat Sheet Nice Cheat Sheet Downloaded from Unusual Locations × 6

Comments (1)

Mr.Champion 15:51 22 Apr 2017

you forgot about the position() method

Reply

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.