Question: Please review my code area keeps equaling 0 . 0 0 when it should be 1 0 . 8 3 using the sample run values
Please review my code area keeps equaling when it should be using the sample run values
Sample Run User input enclosed in
Enter the number of sides:
Enter the side's.length:
My Code
import math
perimeter
apothem
area
def mainperimeter apothem, area:
numberofsides intinputEnter the number of sides:
sidelength floatinputEnter the side's length:
showperimeternumberofsides, sidelength
showapothemnumberofsides, sidelength
showareaperimeter apothem
printfarea:f
def showperimeternumberofsides, sidelength:
perimeter numberofsides sidelength
return perimeter
def showapothemnumberofsides, sidelength:
apothem sidelength math.tanmathradians numberofsides
return apothem
def showareaperimeter apothem:
area perimeter apothem
return area
mainperimeter apothem, area
Question Parameters
Assignment: A regular polygon has sides that are of equal length. The area of a regular polygon can be calculated using this formula:
area perimeter apothem
You can calculate the perimeter with the following formula:
perimeter numberofsides sidelength
The apothem is the distance from the center of the polygon to the midpoint of one of its sides. You can calculate the apothem with this formula:
apothem sidelength math. tanmathradians numberofsides
Note that you need to use the math.tan and math.radians functions in the calculation.
Write a program that prompts the user to input the number of sides an int and the side length a float
Write a function named apothem that calculates the length of the apothem, and a function named area that calculates the area of the polygon.
The program should display the area with only two decimal digits.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
