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 0.00 when it should be 10.83 using the sample run values
Sample Run (User input enclosed in <>)
Enter the number of sides: .<3>
Enter the side's.length: .<5>
10.83
****************************************************
My Code
****************************************************
import math
perimeter =0.0
apothem =0.0
area =0.0
def main(perimeter, apothem, area):
number_of_sides = int(input('Enter the number of sides: '))
side_length = float(input("Enter the side's length: "))
show_perimeter(number_of_sides, side_length)
show_apothem(number_of_sides, side_length)
show_area(perimeter, apothem)
print(f'{area:.2f}')
def show_perimeter(number_of_sides, side_length):
perimeter = number_of_sides * side_length
return perimeter
def show_apothem(number_of_sides, side_length):
apothem = side_length /(2* math.tan(math.radians(180/ number_of_sides)))
return apothem
def show_area(perimeter, apothem):
area =(0.5* perimeter * apothem)
return area
main(perimeter, 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 =0.5* perimeter * apothem
You can calculate the perimeter with the following formula:
perimeter = number_of_sides * side_length
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 = side_length /(2* math. tan(math.radians(180/ number_of_sides)))
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!