Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please read all instructions carefully before submission. Failure to follow guidelines will result in loss of points. Ask for clarification if something is unclear. Purpose:
Please read all instructions carefully before submission. Failure to follow guidelines will result in loss of points. Ask for clarification if something is unclear.
Purpose:
The purpose of this assignment is to organize your code in a structured way using functions. The important concepts are
How to define a function
How to call a function
How to send data to a function parameters
How to get results from a function return value
Requirements:
Write a Python script that prompts the user for the length of a side of a polygon and prints a table of areas of several polygons. Sample output is shown below.
Additional requirements:
Your program should use functions to organize the code. Implement these functions:
main The main function should call the function getsidelength and then send sidelength to report.
getsidelength This function should prompt the userInput the length of a side: and return sidelength to main as an int.
report This function should print a heading line side length...number of sides...area" and use a loop to print a table of values as shown in the sample output below. The report function should call polygonarea to calculate the areas needed for the table. The function report will have to call polygonarea once for each area that it needs to print.
polygonarea This function takes numsides and sidelength as parameters and returns the area of such a polygon. The area of such a polygon is computed by this formula:
area numsides sidelength sidelength
math.tanmathpi numsides
Example output:
Here is the expected structure of your program:
Hierarchv Chart:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started