Closed hayeah closed 8 years ago
hi,
Thank you for your excellent book. A sharp-eyed student in my class raised a question with the circle function:
def circle(t, r): circumference = 2 * math.pi * r n = int(circumference / 3) + 1 length = circumference / n polygon(t, n, length)
We are wondering if n should always be larger than 3, otherwise the polygon function wouldn't work.
So we should have this line instead:
n = int(circumference / 3) + 3
The relevant line in the tex source is here:
https://github.com/AllenDowney/ThinkPython2/blob/9b78593fe9300854de6d7f63fdb722a6a58405b3/book/book.tex#L3210
The polygon function draws a regular n-sided polygon, defined this way:
def polygon(t, n, length): angle = 360 / n for i in range(n): t.fd(length) t.lt(angle)
Good idea. I've made that change in the book and in polygon.py
Thanks!
hi,
Thank you for your excellent book. A sharp-eyed student in my class raised a question with the circle function:
We are wondering if n should always be larger than 3, otherwise the polygon function wouldn't work.
So we should have this line instead:
The relevant line in the tex source is here:
https://github.com/AllenDowney/ThinkPython2/blob/9b78593fe9300854de6d7f63fdb722a6a58405b3/book/book.tex#L3210
The polygon function draws a regular n-sided polygon, defined this way: