Question: Instructions/Design We will write a new module to do more calculations for an additional shape and then update our 'driver' (main) program to call the

Instructions/Design

We will write a new module to do more calculations for an additional shape and then update our 'driver' (main) program to call the new functions.

Note: To ensure your modules are found, put ALL the .py files that constitute our updated geometry program in the SAME directory/folder

Step 1

Write a module named stadium.py that contains TWO function definitions:

  • area (which returns the area of a stadium)
  • perimeter (which returns the perimeter of a stadium)

Note: you will need to import the math module.

Step 2

Update program geometry.py (Program 5-28) from our book to include TWO additional choices. Add these choices to the MENU and call the appropriate method. Here is what user should see:

 MENU 1) Area of a circle 2) Circumference of a circle 3) Area of a rectangle 4) Perimeter of a rectangle 5) Area of a stadium 6) Perimeter of a stadium 7) Quit

Hint on Design

Work on one function at a time in the new module. First get stadium.py's area function working before adding and testing the perimeter function. You MUST get stadium.py is working with the geometry.py 'driver' program.

Stadium Shape

A geometric stadium (Links to an external site.) shape is a circle (Links to an external site.) of radius r that has been cut in half through the center and the 2 ends are then separated by a rectangle (Links to an external site.) of height r and width (or side length) of a. Calculations are essentially a combination of calculations for a combined circle and rectangle.

r = radius a = length side a A = area P = perimeter = pi = 3.14159

Area of a stadium:

A = r2 + 2 * r * a

Perimeter of a stadium:

P = 2 * ( r + a)

Sample Output (your output MUST match)

 MENU 1) Area of a circle 2) Circumference of a circle 3) Area of a rectangle 4) Perimeter of a rectangle 5) Area of a stadium 6) Perimeter of a stadium 7) Quit Enter your choice: 5 Enter the stadium's radius: 7 Enter the stadium's side length: 9 The area is 279.94 MENU 1) Area of a circle 2) Circumference of a circle 3) Area of a rectangle 4) Perimeter of a rectangle 5) Area of a stadium 6) Perimeter of a stadium 7) Quit Enter your choice: 7 Exiting the program...

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 Databases Questions!