Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ScottL Group Title

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:

  • one year ago
  • one year ago

  • This Question is Open
  1. ScottL Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ## 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()

    • one year ago
  2. ScottL Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

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

    • one year ago
  3. ScottL Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ... 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.

    • one year ago
  4. ScottL Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.