Prerequisistes: Turtle Programming in Python
Turtle is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like
turtle.right(…) which can move the turtle around. Let’s create a basic animation where different little turtles race around a track created for them.
- Turtle Module
- Random Module
- Firstly, import the required modules.
- There are different shapes of pointer available in the turtle module(like arrow, classic and turtle). As this is a “Turtle Race”, we need the ‘turtle’ and ‘classic’ shape.
- We’ll use the classic shape to draw the racing track.
- List the specs of the first turtle, enter the turtle in the track and set the turtle ready for the race.
- Do the same for the rest of the turtles.
- Use the
randint()to set the speed of the turtles.
Below is the implementation.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.