Note 4.2.1. Complete the rectangle ….
Modify the program by adding the commands necessary to have alex complete the rectangle.
turtle
. That module brings us two new types that we can use: the Turtle
type, and the Screen
type. The dot notation turtle.Turtle
means “The Turtle type that is defined within the turtle module”. (Remember that Python is case sensitive, so the module name, turtle
, with a lowercase t, is different from the type
Turtle
because of the uppercase T.)alex
is made to refer to this turtle. These first three lines set us up so that we are ready to do some drawing.alex
to move and to turn. We do this by invoking or activating alex’s methods — these are the instructions that all turtles know how to respond to. Here the dot indicates that the methods invoked belong to and refer to the object alex
.exitonclick
method, the program pauses execution and waits for the user to click the mouse somewhere in the window. When this click event occurs, the response is to close the turtle window and exit (stop execution of) the Python program.https://www.w3schools.com/colors/colors_names.asp
pensize
method expects its argument to be an int
. That means you need to convert the string to an int before you pass it to pensize
.import turtle
wn = turtle.Screen()
alex = turtle.Turtle()
alex.forward(150)
alex.left(90)
alex.forward(75)
turtle.Turtle()
to get a new Turtle object?