Teach kids programming using Turtle and Python

Shell-o world: Turtle graphics in Python

Open source code for a better food system, code with grass image
Image credits : 
Photo by Jen Wike Huger

Subscribe now

Get the highlights in your inbox every week.

Turtle graphics is a popular way to introduce young learners to programing. It was part of the original Logo programming language, which, according to Wikipedia, is an educational programming language Seymour Papert and others designed in 1967.

I first encountered Logo as a graduate student in education. As a young adult, I'd struggled with mathematics. Abstract concepts—which others so easily grasped—evaded my understanding, and mathematics became anathema to me. That changed in graduate school, when my assignment was to teach a fifth grade student geometry using a special curriculum that used Logo and Turtle graphics.

One of my teacher colleagues recently shared his strategies for using Turtle graphics with Python. This piqued my interest (due to my earlier experiences). Since Python is included with most Linux distributions, I was eager to meet my old friend the Turtle.

To begin, I needed to install Python's graphical interface, Tkinter. Once I accomplished that, I was ready to begin. I opened a terminal, typed "python," and pressed Enter.

At the Python prompt, I typed "import turtle"—and was ready to begin. At the prompt, I typed, "turtle.forward(100)" and pressed Enter. The graphical interface appeared, and the turtle moved 100 turtle steps forward.

You can use many commands to turn, change the pen color, pick up the pen, change the background color, and more. The Python documentation is very good.

Turtle screenshot

Turtle's real power, however, lies not in its ability to simply execute commands, but its promise for encouraging students to think procedurally and reflect on their thinking. Using Turtle graphics, it's possible for programming students to get immediate visual feedback from their programming and to explore mathematical concepts, including estimation and variability, at the same time. Using a text editor like Gedit or Vi, it's possible to create a simple program for drawing a hexagon, for example. Using the reference materials provided at the Python site and a text editor, I created program to draw a square and executed it.

import turtle turtle.forward(90) turtle.rt(90) turtle.forward(90) turtle.rt(90) turtle.forward(90) turtle.rt(90) turtle.forward(90) turtle.rt(90) turtle.done()

You can accomplish more complex programming operations, too. I saved this simple program as "square.py," then executed it with Python. Here is an example of some more complex scripts by a young programmer I found on the Internet. And here's a YouTube example of a complex design created with a very simple script.

You can easily see that Python Turtle graphics are another example of open source's power to provide a world-class programming environment that is extremely affordable.

About the author

Don Watkins - Educator, entrepreneur, open source advocate, life long learner, Python teacher. M.A. in Educational Psychology, MSED in Educational Leadership, Linux system administrator, Follow me at @Don_Watkins .