more ramblings of a retired teacher
commenting (maybe ranting) on education - even my own
Categories:

Archives:
Meta:
September 2017
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
252627282930  
03/18/15
Explore
Filed under: General, Education, coding/programming
Posted by: Algot @ 3:05 pm

Turtle Python

Back in the days when we used the AppleII at the middle school where I taught, we used a package called Delta
Drawing
which had some of the features of Logo, the language developed by Wally Feurzeig and Seymour Papert to help develop early programming skills, even for elementary students. For a while Logo was
popular, but as administrators challenged the value of “Programming for
Everybody”, it fell by the wayside as BASIC had earlier. Apparently neither Logo nor BASIC were important enough to be part of the “back to basics” thinking that came with budget cuts.

The STEM initiative (Science, Technology, Engineering, Math) is having some success in education circles these days. In that context programming
is making a resurgence with the support of some heavy hitters in the tech world having political impact.
The “Hour of Code” effort is popular. Python is one of the languages
with traction, too. Python has Turtle Graphics available as a built-in
module. It is possible to use Python programming to do turtle graphics
in almost the same way they were done in earlier Logo implementations.

Turtle graphics are a very good way to introduce the concept of functions in Python.

I purchased a book from a member of the MathFuture Google Group.

Hacking Math Class with Python: Exploring Math Through Computer Programming by Peter Farrell [Link]

His book begins with a section on turtle graphics.

Typing the following code into the command line (Python interpreter
running) window will produce first a square and then a circle in a popup
window (using the built-in tk windowing tools).


python
	
from turtle import *
	
def square():
   for i in range(4):
       fd(100)
       rt(90)
square()
	
def circle():
    for i in range(36):
        fd(10)
        rt(10)
	
circle()

You might not be surprised that those instructions made a square and circle.

If you learned Logo, you will recognize the fd 100 as meaning “move
the turtle forward 100 steps.” Likewise, rt(90) was rt 90 or right 90
depending on the implementation of Logo you used. What is different is
the indenting of Python and the use of parentheses to indicate the
functions in use along with the Python structure of the loop which was
different in Logo.

Implementing a Logo-like turtle graphics environment in Python does
give us immediate access to visualizing the concepts expressed as
functions, a real leg up in the concept of functions in math.

That, of course, lead me to remember the “flowering” of my earlier
Logo days, and I made the rotations of both square and circle that were
such a rush for me back then.

I exemplified a bit of my sponsored wordnik word “explore” by making a
challenge to do a stack of polygons with one side overlapped
(congruent?).


>>> clear()
>>> lt(60)
>>> octogon()
>>> hexagon()
>>> pentagon()
>>> square()
>>> triangle()
	

I think I may enjoy going further in the book.

One Response to “Explore”

  1. Peter Farrell Says:
    Hi, Algot, Thanks for the thoughtful post on learning programming through Turtle geometry. Ever since discovering Mindstorms and Logo, I’ve been amazed that a few lines of code can lead to such complicated (even beautiful) designs. Good point about Python’s loops being different from Logo’s. Some days I’d prefer to just type “repeat(10)” or something. My Logo-Python path came full-circle last night. I was teaching a little girl to draw the designs in my book but since she’s a very slow typist we were using Scratch, which is just drag-and-drop Logo code. Best of luck, Peter Farrell