Answered step by step
Verified Expert Solution
Link Copied!

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 get_side_length and then send side_length to report.
get_side_length This function should prompt the user("Input the length of a side: ") and return side_length 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 polygon_area to calculate the areas needed for the table. The function report will have to call polygon_area once for each area that it needs to print.
polygon_area This function takes num_sides and side_length as parameters and returns the area of such a polygon. The area of such a polygon is computed by this formula:
area =(num_sides * side_length * side_length)}
/(4* math.tan(math.pi / num_sides))
Example output:
Here is the expected structure of your program:
Hierarchv Chart:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Discuss whether we can control stereotyping.

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago