Created
May 4, 2017 03:06
-
-
Save nasturtus/0736a2ed04f211cfd13924a17f0d510f to your computer and use it in GitHub Desktop.
This file contains 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
# http://greenteapress.com/thinkpython2/html/thinkpython2005.html | |
import turtle | |
import math | |
def polygon(t, n, length): | |
angle = 360 / n | |
print(angle) | |
for i in range(n): | |
t.fd(length) | |
t.rt(angle) | |
# Use polygon to draw a circle | |
def circle(t, radius): | |
circumference = 2 * math.pi * radius | |
print(circumference) | |
n = int(circumference / 3) | |
print(n) | |
length = circumference / n | |
print(length) | |
polygon(t, n, length) | |
bob = turtle.Turtle() | |
circle(t=bob, radius=100) # keyword arguments for greater readibility | |
turtle.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment