June 15th, 2013, 12:57 PM

"Think Python" 4.3 #4 Exercise (turtle circle function)
edit: Ugh nevermind I'm an idiot...the book explains it if you keep reading. I thought I would wait until I solved this problem before I read on, but it shows you how if you keep going.
Hello, I'm having a little trouble solving a problem from the book "Think Python." The problems are here under 4.3 Exercises.
For #4 here is what I have
Code:
from swampy.TurtleWorld import *
import math
world = TurtleWorld()
bob = Turtle()
bob.delay = 0.01
print bob
def square(t, length):
for i in range(4):
fd(t, length)
lt(t)
def polygon(t, length, n):
for i in range(n):
fd(t, length)
lt(t, 360 / n)
def circle(t, r):
circumference = 2 * math.pi * r
n = int(circumference)
polygon(t, 1, n)
circle(bob, 30)
wait_for_user()
The problem is that if I make the radius too big (somewhere between 10 and 20) then the turtle does not make a complete circle. It stops before the circle completes.
I tried to just use straight up circumference because I thought maybe using int was making it so there were not enough "sides" but then I get an error saying that an integer was expected n and it can't be a float.
What can I do to make the turtle draw a complete circle regardless of how large the radius is?
Thanks for the help!
Last edited by Suboptimalplay; June 15th, 2013 at 02:11 PM.
Reason: figured it out