Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Moving the Turtle

00:00 Programming with turtle. This section will be broken up into four main parts: moving the turtle, drawing shapes, altering the turtle, and some other functions.

00:14 So, let’s get started by looking at moving the turtle. Moving the Turtle. Here, you will see all of the steps needed. Firstly, importing the turtle library.

00:28 Creating a new screen, referenced by s, and a turtle, referenced by t. Our turtle has four movement commands: forward and backward, which need distance as a parameter,

00:59 and left and right, which need an angle as their parameter. As these might be a little long-winded to type, there are abbreviations for each of them. .goto() makes use of the coordinate system which is present on the turtle canvas.

01:32 It’s useful to be aware of the coordinates that are onscreen, as sometimes it can make programming simpler to directly move the turtle to a location or measure its position.

01:43 As you can see onscreen, the coordinate system starts with (0,0) at the center. Moving to the right gives positive values of the x coordinate and moving to the left gives negative values.

01:54 A similar situation exists for the y coordinate, where an upwards movement from the home position is positive and a downwards movement is a negative one.

02:03 Each quadrant has a characteristic combination of positive and negative values for x and y. .goto() uses these two coordinates to send the turtle to a specific location, as you can see here.

02:29 .home() sends the turtle back to the home location, which is the same as .goto(0,0). It’s possible to obtain the turtle’s current position with the .pos() command.

02:53 Mimicking the original physical turtle, there are the .penup() and .pendown() commands, which control whether the turtle leaves a track behind it as it moves around onscreen.

03:20 Let’s send the turtle home, and then make use of the .clear() command to clear everything it’s drawn so far. Now that you’ve seen how to move the turtle, in the next section, you’ll take a look at getting it to draw some more complex shapes.

Become a Member to join the conversation.