Hey there, young coder! 😎 Ever wanted to draw shapes and cool designs using Python? Well, you’re in the right place! In this post, we’re going to learn how to use Python’s Turtle module to create awesome drawings—while learning some cool coding skills along the way.
What is Turtle Graphics? 🐢
Python’s Turtle module is a super fun way to start coding. Imagine you have a turtle on your screen, and you can control it with your Python code. You can tell it to move around, draw lines, and make all kinds of shapes! The best part? You get to watch everything happen in real-time.
Just like a real turtle moves slowly, your virtual turtle will follow your instructions to draw shapes, patterns, and even cool designs. All you need is Python, and we’ll get started with some simple commands.
Setting Up Your Turtle 🐢
Before we dive in, make sure you have Python installed on your computer. If you don’t have it yet, just head over to python.org and download the latest version.
Once you’ve installed Python, you’re good to go! The Turtle module comes with Python, so no extra downloads are needed.
Running Your Code: Step-by-Step 🚀
Now that you have Python installed, let’s talk about how to write and run your Python code!
Step 1: Choose a Code Editor 🖥️
You’ll need a code editor to write your Python code. Here are some cool options for beginners:
- IDLE: Python comes with its own built-in editor called IDLE. It’s easy to use and perfect for beginners.
- VS Code: A popular free editor that’s great for all kinds of programming (get it from here).
- Thonny: A beginner-friendly editor specifically for Python (get it from here).
Step 2: Open the Editor 📝
Once you’ve chosen your editor, open it up and create a new file. Save the file with a .py
extension (for example, turtle_art.py
). This tells Python that it’s a Python file.
Step 3: Write Your Code ✍️
Now you’re ready to start coding! Type your Python code in the editor. Here’s the first example where we draw a square:
import turtle # Import the turtle module
# Create the turtle object
pen = turtle.Turtle()
# Loop to draw a square
for i in range(4): # We need 4 sides for a square
pen.forward(100) # Move the turtle forward by 100 units
pen.left(90) # Turn the turtle left by 90 degrees
# Keep the window open until clicked
turtle.done()

Step 4: Run the Code 🚦
Once you’ve written your code, it’s time to run it and see the magic! Here’s how:
- In IDLE: Press F5 or go to Run > Run Module to run your code.
- In VS Code: Open the integrated terminal (press **Ctrl +
** or go to **View > Terminal**) and type
python yourfile.py(replace
yourfile.py` with the name of your file). - In Thonny: Just click Run at the top, and the turtle graphics will pop up!
Your First Drawing: A Square 🟦
Let’s start simple. We’ll tell the turtle to draw a square. Are you ready? Let’s do it!
import turtle # Import the turtle module
# Create the turtle object
pen = turtle.Turtle()
# Loop to draw a square
for i in range(4): # We need 4 sides for a square
pen.forward(100) # Move the turtle forward by 100 units
pen.left(90) # Turn the turtle left by 90 degrees
# Keep the window open until clicked
turtle.done()
What’s Happening in the Code? 🤔
import turtle
: This line tells Python that we’re using the Turtle module.pen = turtle.Turtle()
: This line creates a turtle, and we name it “pen.”for i in range(4)
: This is a loop. It repeats the same steps 4 times—one for each side of the square.pen.forward(100)
: This makes the turtle move forward by 100 units (you can think of it as steps).pen.left(90)
: This turns the turtle left by 90 degrees so it can make the next side of the square.
And that’s it! You’ve just drawn a square using Python and Turtle! 🎉
Add Some Color to Your Art 🎨
Now, let’s add some color to make things more exciting. You can change the color of your pen by adding this line of code:
pen.color("blue") # Change the pen color to blue
Now, your turtle will draw in blue! You can use any color you want. Try out different colors like “red”, “green”, or “yellow” and see what happens.
Let’s Get Creative: Draw a Star ⭐
How about something a little more challenging? Let’s make a star! Stars are fun to draw with Python because you can see the turtle moving in different directions. Here’s how to do it:
import turtle
pen = turtle.Turtle()
# Loop to draw a star
for i in range(5): # A star has 5 points
pen.forward(100) # Move forward by 100 units
pen.right(144) # Turn right by 144 degrees
turtle.done()

What’s Happening Here?
pen.forward(100)
: The turtle moves forward by 100 units, just like before.pen.right(144)
: This turns the turtle right by 144 degrees. The turtle needs to turn this much to create a star shape!
After running this code, you’ll see a beautiful star shape appear on your screen! 🌟
Let’s Make It a Spiral! 🌪️
Want to go a step further? You can make your turtle draw spirals by using a loop and changing the pen’s direction gradually. Here’s a simple spiral you can create:
import turtle
pen = turtle.Turtle()
# Loop to draw a spiral
for i in range(50): # We’ll repeat this 50 times
pen.forward(i * 10) # Move forward by increasing steps
pen.left(45) # Turn left by 45 degrees
turtle.done()

What’s Happening?
pen.forward(i * 10)
: Each time, the turtle moves a little farther forward. It starts with 10 units, then 20, then 30, and so on!pen.left(45)
: The turtle turns left by 45 degrees each time, making a spiral effect.
Now you have a cool spiral design! 🌪️
Your Next Steps
You’ve just learned the basics of Turtle graphics, and now it’s time to get creative! Here are some ideas for what you can try next:
- Draw different shapes: Can you draw a triangle, hexagon, or pentagon? Try adjusting the angles and side lengths!
- Make patterns: Use loops to create repeating patterns. Try drawing multiple shapes in a circle.
- Play with colors: Change the pen’s color and background color. Can you make a rainbow pattern?
- Create your own designs: Let your imagination run wild and use what you’ve learned to make your own art.
Conclusion! 🎉
I hope you had fun drawing with Python’s Turtle module! Keep experimenting with different shapes, colors, and designs. If you make something cool, share it in the comments below—I’d love to see your creations!