## ScottL 2 years ago Hi, could someone take a look and see what the problem is, please. The problem is with the equation in f_sizeAngle(). I am trying to get an app to draw a geometric shape defined by the number I enter for sides. For example, I enter 3 to draw a triangle. f_sizeAngle() assumes a regular polygon. According to that equation, for a triangle, it should send 60 for angle size to f_draw(). However, the angles that get drawn are closer to 100 degrees. I will post it next post:

• This Question is Open
1. ScottL

## create a program where the user can request a turtle to draw the object of choice. ## the object will be selected by entering the number of sides the object contains. ## the program will use the sides to calculate the size of the angle and will forward this ## information to a function that will draw the object from swampy.TurtleWorld import * world = TurtleWorld() bob = Turtle() t = Turtle() sides = int() print bob def f_enterSides(sides): ## careful since raw_input is a string value it must be converted to integer before being ## passed on to f_sizeAngle() or there will be a type error x = raw_input("Please enter the number of sides of the object: " ) int_x = int(x) f_sizeAngle(int_x) ## compute size of angle from number of sides def f_sizeAngle(sides): n = int(sides) sizeAngle = (n - 2) * 180 / n ## with sides/n = 3, sizeAngle should = 60. however, it doesn't f_draw(sizeAngle, n, t) ## draw object def f_draw(sizeAngle, sides, t): for i in range (sides): fd(t, 100) lt(t, sizeAngle) print t ## f_sizeAngle(3) f_enterSides(sides) ##wait_for_user()

2. ScottL

my guess would be that the swampy module must define angle as external, and my equation is internal....

3. ScottL

... when I enter 4 for sides (iow, a square) it works. the angles are drawn corrently. but anything smaller or larger than 90 degrees is off.

4. ScottL

changing sizeAngle = 360 / n is the answer. so i guess i was using interior and the module was using exterior.... thanks y'all, for lettin me think out loud