Skip to content

Both.org

News, Opinion, Tutorials, and Community for Linux Users and SysAdmins

Primary Menu
  • About Us
  • Computers 101
    • Hardware 101
    • Operating Systems 101
  • End of 10 Events
    • Wake Forest, NC, — 2025-09-20
  • Linux
    • Why I use Linux
    • The real reason we use Linux
  • My Linux Books
    • systemd for Linux SysAdmins
    • Using and Administering Linux – Zero to SysAdmin: 2nd Edition
    • The Linux Philosophy for SysAdmins
    • Linux for Small Business Owners
    • Errata
      • Errata for The Linux Philosophy for SysAdmins
      • Errata for Using and Administering Linux — 1st Edition
      • Errata for Using and Administering Linux — 2nd Edition
  • Open Source Resources
    • What is Open Source?
    • What is Linux?
    • What is Open Source Software?
    • The Open Source Way
  • Write for us
    • Submission and Style guide
    • Advertising statement
  • Downloads
  • Home
  • Learning with the turtle
  • Linux
  • Programming
  • Python

Learning with the turtle

Don Watkins June 20, 2024 5 minutes read
Turtle

Image by: Patti Black on Unsplash

Mathematics was anathema to me in my early years. As a visual learner, abstract concepts were challenging for me. However, in graduate school, I had to teach a fifth-grade student geometry using a unique curriculum involving Apple Logo and Turtle graphics. This experience changed my perspective on math.

My transformative journey with Turtle graphics began about nine years ago when I serendipitously discovered the ‘Turtle’ module for Python at a workshop. Python is readily available on most Linux distributions, so I eagerly embraced the Turtle. Learning to use the ‘turtle’ module introduced me to Python and opened up a world of creativity and learning. I’ve been fortunate to share this journey with others, especially young people eager to create turtle graphics and explore the fascinating intersection of programming and mathematics.

My first experiences with Python began in the terminal and the REPL (read eval print-loop).

I have used several development environments in my Python journey, including IDLE, VS-Codium, and VS Code. In this article, I am using VSCodium on Linux. 

Keeping things simple, I begin with a simple program to draw a square. I need to add a couple of lines of code to keep the window open so I can show the students the code and they can see the graphical representation. I teach the students the importance of adding comments to their code, which helps them remember what each code block is for and explain what is happening to others they might be sharing their code with. Comments are denoted with the hash ‘#’

That code is:

# This is the code to add the turtle library
import turtle

# This is the code to add the drawing window

window = turtle.Screen()

# This is the code to close the drawing window

window.exitonclick()

Next, I showed them how to draw a simple square using a turtle. 

# This is the code to import the turtle function

import turtle

# This is the code to open the drawing window

window = turtle.Screen()

# This is the code to draw the square

turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)

# This is the code to close the window

window.exitonclick()

I show them how to simplify and iterate their code using a ‘for’ loop. The ‘for’ loop produces the same square as illustrated above but with far less code.

# import the turtle function
import turtle

# This is the code to open the drawing window
window = turtle.Screen()

# The range function to create the square

for x in range(4):
   turtle.forward(100)
   turtle.right(90)

# This is the code to close the window

window.exitonclick()

I show them how to give the ‘turtle’ different names and create more than one turtle. I introduce the students to objects and show them how to create a unique ‘turtle’ object using a name. In this case I will use the name ‘jeff.’ .  All of these iterations produce the same figure illustrated above but are building blocks for later use.

# import the turtle function

import turtle

# Create a separate turtle named jeff

jeff = turtle.Turtle()

# This is the code to open the drawing window

window = turtle.Screen()

for x in range(4):
   jeff.forward(100)
   jeff.right(90)

# Code to close the drawing window 

window.exitonclick()

I demonstrate that we can create a simple square spiral by changing our code slightly. 

# import the turtle function

import turtle

# Code to open the drawing window

window = turtle.Screen()

# code to create a turtle with a name

jeff = turtle.Turtle()


for x in range(50):
   jeff.forward(200)
   jeff.right(92)

I gradually introduced more complexity in each of the programming examples and then let the students’ imaginations and nascent programming run wild. In the code below, I have added ‘color’, ‘pensize’, and ‘speed’ iterations to the code, along with changing the range and the distance the ‘turtle’ moves forward. The ‘speed’ is set to zero, the fastest drawing speed available.

# import the turtle function
import turtle

# code to create drawing window

window = turtle.Screen()

# Create a separate turtle object with colors and details

jeff = turtle.Turtle()
jeff.color("blue")
jeff.pensize(3)
jeff.speed(0)


for x in range(50):
   jeff.forward(200)
   jeff.right(92)


window.exitonclick()

Many options within the ‘turtle’ library provide many opportunities to work with beginning programmers. There are endless possibilities when you use Python and other open-source tools combined with your imagination and those of your students. Here’s one final code snippet that demonstrates more complex Python programming.

# Draw a circle spiral with four colors

# import the turtle function

import turtle

# create the drawing window

window = turtle.Screen()

# set the drawing speed to zero which is the fastest

turtle.speed(0)

# list the colors in the circle spiral

colors = ["red", "brown", "blue", "green"]


for x in range(100):
    turtle.pencolor(colors[x%4])
    turtle.circle(x)
    turtle.left(91)

# close the drawing window

window.exitonclick()

Turtle graphics is not just a tool for executing commands but a gateway to encourage students to think procedurally and reflect on their thought processes. It provides instant visual feedback on code, allowing students to explore mathematical concepts and unleash creativity. You can easily see that Python Turtle graphics are a great example of open source’s power to provide an extremely affordable, world-class programming environment.

Tags: Mathematics Turtle

Post navigation

Previous: How my easy, home-made backup program saves time, space on the storage medium, and network bandwidth
Next: Open source in organizations

Related Stories

Typewriter-lead
  • Books
  • Linux
  • Printing
  • Using and Administering Linux

Book Update — Chapter 26, Printers

David Both May 1, 2026
connections_wires_sysadmin_cable
  • Linux
  • Networking
  • Router

How to Make your Linux Box Into a Router

David Both April 29, 2026
f44-01-day-cropped
  • Fedora
  • Linux
  • Upgrades

Fedora 44 Released

David Both April 28, 2026

System upgrades this Sunday, May 3

Tools illustrationFedora 44 was released this week and I’ve upgraded all my systems except for the two that directly affect Both.org. I’ll be upgrading the hosts for my server and firewall to Fedora 44 this Sunday afternoon, May 3.

Both.org will be down for most of the afternoon for these upgrades.

Thanks for your patience.

Random Quote

Unix is user-friendly. It just isn’t promiscuous about which users it’s friendly with.

— Steven King

Why I’ve Never Used Windows

On February 12 I gave a presentation at the Triangle Linux Users Group (TriLUG) about why I use Linux and why I’ve never used Windows.

Here’s the link to the video: https://www.youtube.com/live/uCK_haOXPFM 

Why there’s no such thing as AI

Last October at All Things Open (ATO) I was interviewed by Jason Hibbits of We Love Open Source. It’s posted in the article “Why today’s AI isn’t intelligent (yet)“.

Technically We Write — Our Partner Site

Our partner site, Technically We Write, has published a number of articles from several contributors to Both.org. Check them out.

Technically We Write is a community of technical writers, technical editors, copyeditors, web content writers, and all other roles in technical communication.

Subscribe to Both.org

To comment on articles, you must have an account.

Send your desired user ID, first and last name, and an email address for login (this must be the same email address used to register) to subscribe@both.org with “Subscribe” as the subject line.

You’ll receive a confirmation of your subscription with your initial password as soon as we are able to process it.

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

License and AI Statements

Both.org aims to publish everything under a Creative Commons Attribution ShareAlike license. Some items may be published under a different license. You are responsible to verify permissions before reusing content from this website.

The opinions expressed are those of the individual authors, not Both.org.

You may not use this content to train AI.

 

Advertising Statement

Both.org does not sell advertising on this website.


Advertising may keep most websites running—but at Both.org, we’re committed to keeping our corner of the web ad-free. Both.org does not sell advertising on the website. Nor do we offer sponsored articles at this time. We’ll update this page if our position on sponsorships changes.

We want to be open about how the website is funded. Both.org is supported entirely by David Both and a few other dedicated individuals.

 

 

Copyright © All rights reserved. | MoreNews by AF themes.