## Tiny Organ Chips

dark mode light mode Search Menu
Search

# My Best Computer Science Lesson

Petful

I am not prone to strong statements, however in my classroom I have come to see one lesson stand above all others for a certain type of learner. Coding can be off putting for some, and it can be hard to sway students who are content being end-users of technology. Others see themselves as less than capable with technology, and many coding challenges can end up reinforcing this belief. However, I have found that this simple Python lesson on iterations and turtle graphics can transform even the most skeptical student into believers.

Originally developed by Seymour Papert, Cynthia Solomon, and Wally Feurzeig in 1969, the turtle was a turtle-shaped mechanical robot that roamed about the floor drawing shapes with an attached pen. The user programmed the turtle using a language called LOGO, one of the first languages built specifically for teaching technology. As a homage, many modern languages today, like Java and Python, have classes and libraries that allow users to draw graphics with the turtle.

I have been using the turtle as a part of my Python unit to teach about basic programming fundamentals like variables, looping, and functions. After a brief introduction on importing libraries in Python and how to use the turtle’s functions, the lesson asks the programmer to move the turtle forward 100 pixels and turn right. The code to complete this is rather simple:

```from turtle import *
Turtle = new turtle()
Turtle.forward(100)
Turtle.right(90)
```

Even very hesitant and new learners can accomplish this task easily. So far the lesson is very accessible, but it is also still sort of bland. That skeptical student most likely will still be skeptical. The next challenge for the programmer is to make a square using a for loop – another accessible challenge. Once students learn the syntax of the for loop and how indentation works in Python, the task is fairly easy:

```from turtle import *
Turtle = new turtle()
for count in range(0,4):
Turtle.forward(100)
Turtle.right(90)
```

After this, I prompt the students with their first real challenge – how can we change the code in this loop to not draw a square, but a decreasing spiral. At this point, brows can get furrowed or agile programmers can get determined. They are going to have to work to complete this one. Very often I assist by prompting them. As they work I ask, “What happens to the length of the sides in a spiral?,” and “What variable in a loop is getting larger each time the loop iterates?” At this point, some of the students figure out that increasing the range of the loop and moving the turtle forward 100-count is the solution they are looking for.

The first “whoas” begin to come from different parts of the room as the students see Moire patterns (interference patterns) visible when the turtle makes a spiral. However, the real magic comes next. I point out to them that a spiral is a simple repeating pattern and changing the angle in the loop can have some interesting effects. I tell them that 71 and 137 are some of my favorite angles. This is usually where the classroom really explodes with excitement. All around the room, students are testing out different angles and seeing unique repeating patterns spill across the screen. Students even get possessive over the spiraling shapes they create, covering their code with their hands.

From here as we move on to cover color and randomization, the class has a different feel. Students have forgotten, even for a class period, about their struggles and have engaged with technology in a playful, childlike way. As they file out of the class, many of them smiling or talking about their creations, again I am reminded about that important lesson for educators – that play really is a powerful teacher.

Note: Try this code on the Repl.it website (select Python with Turtle) if your computer doesn’t have Python. You may have to use Repl.it examples and tweak code.

#### Turtle Graphics

https://en.wikipedia.org/wiki/Turtle_graphics

#### Introducing Turtle Graphics for Python

https://repl.it/site/blog/python-turtle

#### Turtle Graphics for tk Docs (used by Repl.it)

https://docs.python.org/2/library/turtle.html