Home > Uncategorized > Turtle Sets the Bar for Python Programming

Turtle Sets the Bar for Python Programming

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:
  1. No comments yet.
  1. No trackbacks yet.