HOME/Articles/

squareTurtle (snippet)

Article Outline

Python example 'squareTurtle'. Turtle lets you draw with Python, this draws a square.

Functions in program:

  • def square():

Modules used in program:

  • import turtle

squareTurtle

Python beginners example: squareTurtle

import turtle

def square():
    win = turtle.Screen()
    win.bgcolor("white")
    jack = turtle.Turtle()
    for x in range(1,5):
              jack.forward(100)
              jack.right(90)
    win.exitonclick()

square()