Learning goals

  • Use short names for turtle commands.
  • Import turtle with the shorter name t.
  • Rewrite a turtle program with fewer letters.

Why type less?

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.

How do you use short commands?

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.

How do you name Turtle?

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)

Animation of Turtle using short commands to move and turn.

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..

Can you rewrite a program?

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)

Summary

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.