June 15th, 2013, 12:57 PM
Join Date: Jun 2013
Time spent in forums: 1 h 32 m 54 sec
Reputation Power: 0
"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
from swampy.TurtleWorld import *
world = TurtleWorld()
bob = Turtle()
bob.delay = 0.01
def square(t, length):
for i in range(4):
def polygon(t, length, n):
for i in range(n):
lt(t, 360 / n)
def circle(t, r):
circumference = 2 * math.pi * r
n = int(circumference)
polygon(t, 1, n)
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