Created
August 25, 2014 11:11
-
-
Save jsstrn/6e99f522038d0f068846 to your computer and use it in GitHub Desktop.
Drawing geometric shapes in Python using Turtle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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