Click here to Skip to main content
14,870,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I got this as an exam test i need help with it

 You are going to write a function called 
get_angle_sizes()
this will take a single value that represents the number of sides of the regular polygon and will return the total of all of the internal angles (the angle sum) and the size of a single internal angle.

If you know how many sides a regular polygon (n) has then you can use this number to calculate the angle sum like this:
Angle sum = (n - 2) x 180
If n is the number of sides then to work out the size of a single angle we just need to divide the Angle Sum  by the number of sides. You can either redo the calculation for the Angle sum or just use the value calculated previously:
Interior Angle = (Angle Sum)/n
or
Interior Angle = ((n - 2) x 180)/n 
**Then it wants**
 
Test the function works correctly and output the results.
Output the results for a regular hexagon (6 sides) and a regular decagon (10 sides). The outputs should match the formatting below exactly.
A regular hexagon has 6 sides, an Angle Sum of xx degrees and an Interior Angle Size of yy degrees
Where xx and yy are the values that 
get_angle_sizes()
returns when given an argument of 6.
And then do the same for the decagon:
A regular decagon has 10 sides, an Angle Sum of xx degrees and an Interior Angle Size of yy degrees 

I have been stuck on this question for a while this what i coded please if you could help comment!

What I have tried:

<pre>def get_angle_sizes(n): 
    if(n < 3): 
        return 0
    return (n - 2) * 180,(n - 2) * 180/n
  
# Driver code 

print(get_angle_sizes(6))
Posted
Updated 20-Mar-21 4:15am
Comments
Richard MacCutchan 15-Mar-21 13:14pm
   
You need to explain exactly what help you need. As it stands there is a lot of code still to write, and I am afraid this is not a "write my code" site.
broman234 15-Mar-21 13:19pm
   
I have done the main code.
it outputs the Interior angle and the angle sum but I have no idea how to do this:
outputs should match the formatting below exactly.
A regular hexagon has 6 sides, an Angle Sum of xx degrees and an Interior Angle Size of yy degrees
Where xx and yy are the values that
get_angle_sizes()
returns when given an argument of 6.
And then do the same for the decagon:
A regular decagon has 10 sides, an Angle Sum of xx degrees and an Interior Angle Size of yy degrees
Richard MacCutchan 15-Mar-21 13:49pm
   
You can use simple print statements such as:
print("A regular", end='') # no end of line yet
if sides == 6
    print("hexagon", end='')
if sides == 10
    print("decagon", end='')
print(" has ", sides, "sides", end='')
print(", an Angle Sum of", anglesum, "degrees", end='')
print(" and an Interior Angle Size of", anglesize, "degrees") # end of line after this

1 solution

can you give me the whole code plz
   
Comments
Richard MacCutchan 20-Mar-21 12:27pm
   
Sorry, no. You have to write it yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900