This is a very simple introduction to Turtle graphics. The turtle starts in the middle of the window, moves forward a small distance, turns right, moves forward a slightly longer distance, right again, even further this time… until the distance equals or exceeds a given limit.

Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966.

Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an import turtle, give it the command turtle.forward(15), and it moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise.

# Spiral outwards in an ever-expanding square
#   using Turtle graphics
#   Authour:    Alan Richmond,

from turtle import *

lineLen = inc = 20      # Line starts this long, grows this much
max = 800               # until it's this long
turn = 90               # try different numbers, e.g. 120

#   The line grows longer until it fills the window
while lineLen < max:
    right (turn)
    lineLen += inc


[welcomewikilite wikiurl=”” sections=”Overview” settings=””]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.