Menu

(Solved) : Write Python Program Displays Following Menu Modularize Code Using Procedures Discussed Se Q37159743 . . .

Write a PYTHON program that displays the following menu:

Modularize your code using procedures, as discussed in section11.2. Use a loop to repeat the menu, as discussed in section 11.3.Validate the menu entry. Use the built in constant in theMath library for Pi (instead of putting theliteral value in your code).

Use defensive programming for this assignment. Your program should give the user an error and allow them to re-enter if they enter an unreasonable value (for example, a zero or negative radius for a circle, or an invalid menu choice). You may assume that the user will enter either an integer or floating point number, as appropriate.Geometry Calculator1. Calculate the Area of a Circle2. Calculate the Area of a Rectangle3. Calculate the Area of a Triangle4. QuitEnter your choice (1-4):If the user enters 1, the program should ask for the radius of the circle and then display its area.Use 3.14159 for p. If the user enters 2, the program should ask for the lengthand width of therectangle, and then display the rectangle’s area. If the user enters 3, the program should ask forthe length of the triangle’s base and its height, and then display its area.If the user enters 4, theprogram should end.Input Validation: Display an error message if the user enters a number outside the range of 1through 4 when selecting an item from the menu. Do not accept negative valuesfor the circle’sradius, the rectangle’s length or width, or the triangle’s base or height.Expected Output: 1. Calculate the area of a Circle2. Calculate the area of a Rectangle3. Calculate the area of a Triangle4. QuitEnter your choice (1-4): 1—Area for a Circle—Enter the circle’s radius: -5ERROR: Enter a valid numberPlease enter the radius: 5The answer is: 78.539816339744831. Calculate the area of a Circle2. Calculate the area of a Rectangle3. Calculate the area of a Triangle4. QuitEnter your choice (1-4): 2—Area for a Rectangle—Enter the base: 6Enter the width: -5ERROR: Enter a valid numberPlease enter the width: -4ERROR: Enter a valid numberPlease enter the width: 4The answer is: 24.01. Calculate the area of a Circle2. Calculate the area of a Rectangle3. Calculate the area of a Triangle4. QuitEnter your choice (1-4): 3—Area for a Triangle—Enter the base: 0ERROR: Enter a valid numberPlease enter the base: 5Enter the height: 5The answer is 12.51. Calculate the area of a Circle2. Calculate the area of a Rectangle3. Calculate the area of a Triangle4. QuitEnter your choice (1-4): 5ERROR: Enter a valid number between 1 and 4Please enter your menu choice: 4

Expert Answer


Answer to Write a PYTHON program that displays the following menu: Modularize your code using procedures, as discussed in section…

OR