A simple Python activity to change even the most skeptical students into coding enthusiasts!
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.
Introducing Turtle Graphics for Python
Turtle Graphics for tk Docs (used by Repl.it)
Also In The August 2018 Issue
Create a fun adventure game with sprites using a retro fantasy computer.
Hide information in plain sight using a clever code and a good book.
Logic puzzles help develop reasoning skills useful for programming, computer science, and anything you might do.
Find perfect and fun gifts for your loved ones that teach STEAM concepts and skills.
From light-up bow-ties to conductive thread, you’ll be the life of the party with this STEAM-inspired gear.
A free online test service reveals how much personal data your web browser is giving away.
Add more tools to your command line arsenal, including running mini-scripts and making backup copies.
Use switches to take your robotic creations to the next level.
Create the American flag in SketchUp using this detailed tutorial.
From lasers to supernovas, Berboucha is making science communication a priority.
Code can always be improved. Check out these tips to make you the best programmer you can be!
It’s a programming language unlike any you’ve seen before. Check out this symbolic system designed for mathematical calculations.
It’s a game that’s obsessing the world. Harmful, or a potential gateway to new skills?
Some fun Python code that introduces you to the arcane world of event handling.
New, improved, faster, and sleeker - it’s Scratch 3, your new favourite block language!
Learn about the brilliant algorithm behind all of your GPS devices.
It’s free, comprehensive, and available on-the-go. This cool app helps you master Python faster than ever before.
Open up whole new worlds to explore through these interesting, diverse add-ons.
Links from the bottom of all the October 2018 articles, collected in one place for you to print, share, or bookmark.
Interesting stories about computer science, software programming, and technology for October 2018.