Skip to content

Instantly share code, notes, and snippets.

@jsstrn
Created August 25, 2014 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsstrn/6e99f522038d0f068846 to your computer and use it in GitHub Desktop.
Save jsstrn/6e99f522038d0f068846 to your computer and use it in GitHub Desktop.
Drawing geometric shapes in Python using Turtle
import turtle
def drawSquare(my_turtle):
my_turtle.color("red")
for i in range(4):
my_turtle.forward(100)
my_turtle.right(90)
def drawSomethingCool(my_turtle):
my_turtle.color("yellow")
for i in range(100):
my_turtle.forward(2 * 2 * i)
my_turtle.right(90)
my_turtle.right(45)
def drawSomethingCooler(my_turtle):
my_turtle.color("blue")
for i in range (36):
drawSquare(my_turtle)
my_turtle.right(10)
# create the turle's play pen
canvas = turtle.Screen()
canvas.bgcolor("black")
# create a turtle named mike
mike = turtle.Turtle()
mike.shapesize(2, 2, 2)
mike.color("yellow")
mike.shape("turtle")
mike.speed(10)
# drawSquare(mike)
# drawSomethingCool(mike)
drawSomethingCooler(mike)
# exits the screen when clicked
canvas.exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment