Python beginner cheatsheet, playing with turtles
Sets the pen state to be up (not drawing).
Sets the pen state to be down (drawing).
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”, ...)
To fill a figure, use turtle.begin_fill() before you start drawing the figure. Draw the figure. Then execute turtle.end_fill(). The figure drawn between the two fill commands will be filled with the present color setting.
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”.
Returns the x - coordinate / y - coordinate of the current pen position.
Close the turtle drawing window
Turns the direction that the turtle is facing right (clockwise) by the amount indicated (in degrees).
Turns the direction that the turtle is facing left (counter clockwise) by the amount indicated (in degrees).
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.
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.
Sets the orientation of the turtle to angle. Here are some common directions in degrees:
Moves the turtle to the specified coordinates, drawing a straight line to the destination (x,y) if the pen is down, and not drawing if the pen is up.
Draws a circle of the indicated radius. The turtle draws the circle tangent to the direction the turtle is facing.
Help Us Go Positive!
We offset our carbon usage with Ecologi. Click the link below to help us!