Turtle Movement

By default, the turtle starts facing east, which means to the right side of the screen. We can move the turtle in different directions using various functions.

Moving the Turtle Forward and Backward

To move the turtle forward, we use the forward() method. This method requires a distance parameter, which tells the turtle how many pixels to move.

# Move the turtle forward by 100 pixels
turtle.forward(100)

Similarly, to move the turtle backward, we use the backward() method. This method also requires a distance parameter.

# Move the turtle backward by 50 pixels
turtle.backward(50)

Turning the Turtle

We can change the direction the turtle is facing by using the right() and left() methods. These methods require an angle parameter, which tells the turtle how many degrees to turn.

To turn the turtle to the right (clockwise), we use the right() method.

# Turn the turtle right by 90 degrees
turtle.right(90)

To turn the turtle to the left (counterclockwise), we use the left() method.

# Turn the turtle left by 45 degrees
turtle.left(45)

By combining these movement and turning commands, we can create complex drawings. Here is an example of using these commands together:

import turtle

turtle.forward(300)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(300)


Included in the following specifications:
KS3 Computing