An adaptation of the chapter's example can also be done in a script. If you've set up Python so that a program can be run in a script, copy the following code into a file named turt.py (in Windows, you might need to be careful about setting the ".py" suffix properly).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
import turtle
import time
print(turtle.position())
time.sleep(1)
turtle.forward(50)
time.sleep(1)
turtle.left(90)
time.sleep(1)
turtle.forward(50)
time.sleep(1)
turtle.right(90)
time.sleep(1)
turtle.forward(50)
time.sleep(1)
turtle.left(90)
time.sleep(1)
turtle.forward(50)
time.sleep(1)
turtle.right(90)
time.sleep(1)
turtle.forward(50)

Be careful not to copy the numbers (1 through 21) and only copy the code into the turt.py file. Then open a command shell in the same directory as turt.py and run the command:

> python -i turt.py

(the "-i" tells Python to remain running after the script in turt.py completes). You can see in the code above all the "time.sleep(1)" statements -- each of these statements cause Python to pause for one second. The pauses nicely allow you to watch the turtle drawing.