Learning Python’s Turtle Module

Emily Bolten
4 min readMay 29, 2019

--

Learning how to code doesn’t take only five minutes, it can actually take several years to do. While getting started with learning to code is very intimidating and difficult, many questions are raised. One of the greater ones being: Where do I begin?

How can you make programming fun and less intimidating to begin working with? One way I found useful was by beginning small and learning something that can be enjoyable for anybody. That thing for me was Python’s Turtle module. Without a bit of background in coding, I began with Python’s Turtle module and learned simple tricks like importing modules, using loops and methods, and how Python’s syntax looks like.

First, if you don’t have Python on your computer, you can download it here:

https://www.python.org/downloads/

This link will take you to where to download Python onto your computer, and it will take you around five minutes to download, the extension for Python is .py, you can use any text editor you would like or you could simply use Python’s IDLE, which you can download with Python. Then you will be able to make programs in Python. Now to get into your program:

First, you need to import a module in Python. A module is something you can import in Python and then be able to use all of the methods that the module comes with. You can do so by simply using “import turtle” at the beginning of your program.

Importing the Turtle Module into Your Program.

Then, set what you want your Turtle object to be called — this is the object that will be able to draw. For this post, I will simply call my Turtle object “turtle”. Enter into your IDE or text editor:

Setting the Turtle Object to “turtle.”

Now you can use the Turtle module to draw with your code! This can be useful and it is pretty cool. Now you know how to import a method from a module and store it into a variable.

One simple thing to draw is a square. To draw a straight line, simply write:

Drawing a Straight Line with Turtle.

Then, to move the Turtle object 90 degrees in order to draw a line in the next direction, simply write:

Moving the Turtle Object 90 Degrees Left.

You could copy these two lines four times to draw the full square, however there is a much easier way to do so:

Use a for loop (will loop a command how many times you need it to — for the sake of making a square, we will loop 4 times) to make a square:

In the end, your code should look something like this:

Drawing a Square with Turtle in Python.

And when you run your program, your square should look like this:

Square in Python’s Turtle Module.

Now keep practicing with the Turtle module to create some other cool shapes and images — you’ll get a small concept of how code works visually to produce results and you could even get into coding and want to make more cool projects. I learned to code by getting excited about making cool shapes using Python’s Turtle module. Once I knew how to use the Turtle module thoroughly, I decided I wanted to learn more programming concepts, and that began my career. Programming becomes more fun and beginner-friendly when beginners pick up something that can be simple enough to understand and produces a visual result.

Some examples of other things you can make with Python’s Turtle module:

Writing Hello.
Circle of Circles.

And you can even learn to draw with colors!

Star with Turtle.

Have fun!

Useful to learn how to use Python’s Turtle module:

https://docs.python.org/3.3/library/turtle.html?highlight=turtle

--

--

Emily Bolten

My name is Emily and I am a computer programmer. Here I will post some of the things I have learned throughout my time of programming!