The Turtle robot is a simple machine that was originally created to help teach programming and math by moving around and drawing lines, much like a turtle crawling with a pen. In Python, this idea comes to life with the Turtle module, which lets you control a virtual turtle on your screen. By writing code to move the turtle and draw shapes, Python Turtle exercises make learning to program fun and easy to understand.
Beginning Python programmers can use these exercises to learn basic concepts in Python using the visual tools in the turtle
module. All the code runs in your browser, so you don’t have to install anything.
If you haven’t used the turtle
before, imagine that it’s a little turtle in the middle of a piece of paper with a pen attached to its belly. You can tell it to walk forward and backward or turn left and right. When it walks, it drags the pen along the paper and draws a line. It always starts in the middle of the page, facing right (east).
If you want to experiment, you can do it online on trinket.io/turtle1.
Multiple solutions
Only the image at the end is compared to see if the exercise is correct. So there are multiple solutions possible.
The feedback after each submission shows how close you are to the goal.
Command | Explanation |
---|---|
forward(distance) |
Move forward by the specified distance , in the direction the turtle is headed. |
backward(distance) |
Move the turtle backward by distance , opposite to the direction the turtle is headed. |
right(a) |
Turn to the right with the specified angle a . |
left(a) |
Turn to the left with the specified angle a . |
done() |
Keep the turtle window open in regular Python. |
Use these sources to find more information: