Archive

Archive for the ‘Uncategorized’ Category

Turtle Sets the Bar for Python Programming

May 12th, 2010 jeremy No comments

Last week I was showing a non-programmer friend the basics of coding. We did some interactive programming using the logo-inspired turtle package that comes with Python Tkinter. We did some fun things like drawing random pinwheels.

The final program we wrote drew the tri-force from “The Legend of Zelda.” Here’s the code:

from turtle import *
 
def triangle(size):
    begin_fill()
    for i in range(3):
        forward(size)
        left(120)
    end_fill()
 
def triforce(size):
    color('yellow')
    triangle(size)
    right(120)
    forward(size)
    left(120)
    triangle(size)
    forward(size)
    triangle(size)
 
triforce(100)
done()

Don’t you wish all programming was like that? What if your ajax-driven Python web application’s code was that simple and elegant?

Categories: Uncategorized Tags: