Learning goals
- Use short names for turtle commands.
- Import turtle with the shorter name
t.- Rewrite a turtle program with fewer letters.
Turtle commands have long names, such as forward() and backward().
Python also accepts shorter names for these commands.
Short names mean less typing, while the turtle moves in the same way.
Write the short command after the turtle’s name.
For example, t.fd(80) moves the turtle forward by 80 steps.
| Long command | Short command |
|---|---|
forward() |
fd() |
backward() |
bk() or back() |
right() |
rt() |
left() |
lt() |
The number inside the parentheses tells the turtle how far to move or turn. Each short command does the same job as its long version.
An alias is another name for something in your code.
Most activities use otto as the turtle name. Here, use t instead.
Write import turtle as t to give the Turtle module this alias.
Then write t. before each Turtle command.
import turtle as t
t.fd(80)
t.rt(90)
t.fd(40)
t.bk(40)
t.lt(90)
t.fd(30)

This code moves forward, turns right, and moves again. It then moves backward, turns left, and moves once more.
If your code uses import turtle as otto, change it to import turtle as t.
Then replace every otto. with t..
Rewrite these commands using t and the short command names:
import turtle as otto
otto.forward(80)
otto.right(90)
otto.backward(30)
otto.left(90)
One possible answer is:
import turtle as t
t.fd(80)
t.rt(90)
t.bk(30)
t.lt(90)
| Long name | Short name | What it does |
|---|---|---|
forward() |
fd() |
Moves forward. |
backward() |
bk() or back() |
Moves backward. |
right() |
rt() |
Turns right. |
left() |
lt() |
Turns left. |