Learning goals
- Save and run a Python Turtle program on your computer.
- Explain what
otto.done()does in regular Python.
When you use Turtle in this browser, your code runs inside the website. You do not need to save a Python file or open a separate Turtle window.
Local means that a program runs on your own computer. To use Turtle locally, you need Python and a code editor, such as Thonny.
A Python file is a saved program. Its name ends with .py.
Open Thonny, choose File and then New, and type this program:
import turtle as otto
otto.forward(100)
otto.left(120)
otto.forward(100)
otto.left(120)
otto.forward(100)
otto.done()
Choose File and Save as…. Save the file as triangle.py.
The program imports Turtle, draws a triangle, and then calls otto.done().
In Thonny, choose Run and then Run current script. You can also press F5.
A separate Turtle window should open and show your triangle.
otto.done() at the end?otto.done() tells regular Python to keep the Turtle window open.
You can look at your drawing until you close that window.
This call does not do anything in this browser activity. It is useful when you copy the script and run it in regular Python.
import turtle as otto
otto.forward(100)
otto.done()
| Idea | What it means |
|---|---|
.py file |
A saved Python program. |
otto.done() |
Keeps a regular Python Turtle window open. |