🐢 Python Turtle
Commands – Cheat Sheet
|
Command |
Definition |
Example |
|
import turtle |
Imports Turtle
module |
import turtle |
|
import turtle as
t |
Imports turtle
with short name |
import turtle as
t |
|
turtle.Screen() |
Creates drawing
screen |
screen =
turtle.Screen() |
|
turtle.Turtle() |
Creates turtle
object |
pen =
turtle.Turtle() |
|
turtle.done() |
Keeps turtle
window open |
turtle.done() |
|
turtle.mainloop() |
Keeps program
running |
turtle.mainloop() |
|
forward() / fd() |
Moves turtle
forward |
pen.forward(100) |
|
backward() /
bk() / back() |
Moves turtle
backward |
pen.backward(50) |
|
right() / rt() |
Turns turtle
clockwise |
pen.right(90) |
|
left() / lt() |
Turns turtle
anticlockwise |
pen.left(90) |
|
circle() |
Draws circle or
arc |
pen.circle(50) |
|
shape() |
Changes turtle
shape |
pen.shape("turtle") |
|
color() |
Changes pen
color |
pen.color("red") |
|
fillcolor() |
Sets fill color |
pen.fillcolor("yellow") |
|
pensize() |
Changes pen
thickness |
pen.pensize(5) |
|
speed() |
Controls turtle
speed |
pen.speed(0) |
|
bgcolor() |
Changes
background color |
screen.bgcolor("blue") |
|
penup() / pu() /
up() |
Lifts pen and
stops drawing |
pen.penup() |
|
pendown() / pd()
/ down() |
Puts pen down
and starts drawing |
pen.pendown() |
|
goto() |
Moves turtle to
coordinates |
pen.goto(100,50) |
|
home() |
Returns turtle
to (0,0) |
pen.home() |
|
begin_fill() |
Starts filling
shape |
pen.begin_fill() |
|
end_fill() |
Ends filling
shape |
pen.end_fill() |
|
write() |
Displays text on
screen |
pen.write("Hello") |
|
clear() |
Clears drawings |
pen.clear() |
|
reset() |
Clears and
resets turtle |
pen.reset() |
|
hideturtle() |
Hides turtle
cursor |
pen.hideturtle() |
|
showturtle() |
Shows turtle
cursor |
pen.showturtle() |
|
Common Turtle
Shapes |
Speed Values |
Coordinate
Directions |
|||
|
Shape Name |
Meaning |
Value |
Speed |
|
|
|
"arrow" |
Default arrow
cursor |
0 |
Fastest |
Direction |
Coordinate |
|
"turtle" |
Turtle shape |
1 |
Slowest |
Right |
+X |
|
"circle" |
Circle shape |
3 |
Slow |
Left |
-X |
|
"square" |
Square shape |
5 |
Medium |
Up |
+Y |
|
"triangle" |
Triangle shape |
10 |
Fast |
Down |
-Y |
|
"classic" |
Classic turtle
cursor |
|
|
|
|
📌 Center of Turtle Screen = (0,0)

No comments:
Post a Comment