Problem Definition Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes based on the user's selection. Let the program handle the perimeter and area calculations for circle, rectangle and parallelogram shapes. The program should display a menu of the three shapes, and then allow the user to select one of the options. Accordingly, the program would request from the user to enter the required parameters of the corresponding geometrical shape in floating- point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape prompt the user to see if there are more shapes to process. The program should: interact with the user in a friendly way using a menu listing the different shapes (C: Circle, R: Rectangle, P: Parallelogram). • display an error message for invalid shape options for a parallelogram, keep asking the user until a valid angle (within 0 and 180 degrees) is entered. compute the perimeter and the area for the selected shape using the following table. Circle Rectangle Parallelogram Parameters Radius r Width w Sides Sl and S2 Length h Angle a Perimeter 2 ar 2(w + h) 2(S1 + S2) 0 < a St/2: (SI *S2)sina /2 < as n: (SI *S2)sin(n-a) Area w.h for output, display the values for perimeters using one decimal place and the values for the areas using 3 decimal places as shown in the sample run. Figures 1(a) – 1(f) illustrate sample runs of the program. ****** Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): c ************s Enter the radius of the Circle: 7 Enter your choice (C, R or P): t ERROR> Invalid choice: 't' Enter another shap: (Y/N)? y Shape Perimeter Area Circle 44.0 153.938 Enter another shape (Y/N)? n Figurel (a): Invalid choice Figurel (b): Circle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. ... ... Enter your choice (C,R or P): P Enter your choice (C, R or P): r Enter side1 of the parallelogram: 6 Enter the length of the rectangle: 5.5 Enter side2 of the parallelogram: 7 Enter the width of the rectangle: 6.25 Enter the angle between the sides (in degrees): 60 Shape Perimeter Area Shape Perimeter Area Rectangle 23.5 34.375 Parallelogram 26.0 36.373 Enter another shape (Y/N)? n Enter another shape (Y/N)? N Figurel (d): Parallelogram choice, angle:60 Figurel (c): Rectangle choice *****. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. 2... Enter your choice (c, R or P): P Enter your choice (C, R or P): p Enter sidel of the parallelogram: 3 Enter sidel of the parallelogram: 3 Enter side2 of the parallelogram: 6 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): -1 ERROR> angle value: -1.0 is outside range (0.1801. Enter the angle between the sides (in degrees): 60 Enter the angle between the sides (in degrees): 100 Shape Perimeter Area .. Shape Perimeter Area Parallelogram 18.e 15.s88 ..***.... Parallelogram 18.0 17.727 Enter another shape (Y/N)?n Enter another shape (Y/N)? Y Figurel (f): Parallelogram choice, angle:-1; keep asking the user until valid angle Figurel (e): Parallelogram choice, angle:100

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Write the purpose, input, output and algorithm of this python program 

Problem Definition
Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes based on the user's
selection. Let the program handle the perimeter and area calculations for circle, rectangle and parallelogram shapes. The
program should display a menu of the three shapes, and then allow the user to select one of the options. Accordingly, the
program would request from the user to enter the required parameters of the corresponding geometrical shape in floating-
point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape prompt the user to see
if there are more shapes to process.
The program should:
interact with the user in a friendly way using a menu listing the different shapes (C: Circle, R: Rectangle, P:
Parallelogram).
display an error message for invalid shape options
for a parallelogram, keep asking the user until a valid angle (within 0 and 180 degrees) is entered.
compute the perimeter and the area for the selected shape using the following table.
Circle
Rectangle
Parallelogram
Parameters
Radius r
Width w
Sides Sl and S2
Length h
Angle a
Perimeter
2 ar
2(w + h)
2(S1 + S2)
w.h
) < a Sa/2: (SI*S2)sina
π/2<αs π S1S2)sin (π-a)
Area
for output, display the values for perimeters using one decimal place and the values for the areas using 3 decimal
places as shown in the sample run. Figures 1(a) - 1(f) illustrate sample runs of the program.
***** ***
***********
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
****
Enter your choice (C, R or P): c
***************
Enter the radius of the Circle: 7
Enter your choice (C, R or P): t
ERROR> Invalid choice: 't'
Shape
Perimeter
Area
.....
Circle
44.0
153.938
Enter another shap: (Y'N)? y
******
Enter another shape (Y/N)? n
Figurel (a): Invalid choice
Figurel (b): Circle choice
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Enter your choice (C,R or P): P
Enter your choice (C, R or P): r
Enter side1 of the parallelogram: 6
Enter the length of the rectangle: 5.5
Enter side2 of the parallelogram: 7
Enter the width of the rectangle: 6.25
Enter the angle between the sides (in degrees): 60
Shape
Perimeter
Area
Shape
Perimeter
Area
...
Rectangle
23.5
34.375
Parallelogram
26.0
36.373
.************
Enter another shape (Y/N)? n
Enter another shape (Y/N)? 'N
Figurel (d): Parallelogram choice, angle:60
Figurel (c): Rectangle choice
****
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
....
***
Enter your choice (c, R or P): P
Enter your choice (C, R or P): p
Enter sidel of the parallelogram: 3
Enter sidel of the parallelogram: 3
Enter side2 of the parallelogram: 6
Enter the angle between the sides (in degrees): -1
ERROR> angle value: -1.0 is outside range (0.18e1.
Enter the angle between the sides (in degrees): 60
Enter side2 of the parallelogram: 6
Enter the angle between the sides (in degrees): 100
Shape
Perimeter
Area
Shape
Perimeter
Area
Parallelogram
18.e
15.588
.****
*****.
Enter another shape (Y/N)?n
Parallelogram
18.0
17.727
Enter another shape (Y/N)? Y
Figurel (f): Parallelogram choice, angle:-1;
keep asking the user until valid angle
Figurel (e): Parallelogram choice, angle:100
Your program should:
a) Import required constants and function provided by Python standard library
b) Use meaningful variable names, and meaningful comments to describe the solution.
c) Accept menu options in lowercase or uppercase form (e.g. p and P are both valid options)
d) Use appropriate messaged and a suitable proper output format to display the result (see program sample runs)
e) Name the file containing your Python source code: HW2_SU21_xxxxx.py; where xxxxx is your university ID.
ID should replace the string "xxxx". For example, a student with ID 75600 should submit a file cal
'HW2_SU21_75600.py'.
f) Upload your Python program to Moodle.
Transcribed Image Text:Problem Definition Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes based on the user's selection. Let the program handle the perimeter and area calculations for circle, rectangle and parallelogram shapes. The program should display a menu of the three shapes, and then allow the user to select one of the options. Accordingly, the program would request from the user to enter the required parameters of the corresponding geometrical shape in floating- point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape prompt the user to see if there are more shapes to process. The program should: interact with the user in a friendly way using a menu listing the different shapes (C: Circle, R: Rectangle, P: Parallelogram). display an error message for invalid shape options for a parallelogram, keep asking the user until a valid angle (within 0 and 180 degrees) is entered. compute the perimeter and the area for the selected shape using the following table. Circle Rectangle Parallelogram Parameters Radius r Width w Sides Sl and S2 Length h Angle a Perimeter 2 ar 2(w + h) 2(S1 + S2) w.h ) < a Sa/2: (SI*S2)sina π/2<αs π S1S2)sin (π-a) Area for output, display the values for perimeters using one decimal place and the values for the areas using 3 decimal places as shown in the sample run. Figures 1(a) - 1(f) illustrate sample runs of the program. ***** *** *********** Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. **** Enter your choice (C, R or P): c *************** Enter the radius of the Circle: 7 Enter your choice (C, R or P): t ERROR> Invalid choice: 't' Shape Perimeter Area ..... Circle 44.0 153.938 Enter another shap: (Y'N)? y ****** Enter another shape (Y/N)? n Figurel (a): Invalid choice Figurel (b): Circle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C,R or P): P Enter your choice (C, R or P): r Enter side1 of the parallelogram: 6 Enter the length of the rectangle: 5.5 Enter side2 of the parallelogram: 7 Enter the width of the rectangle: 6.25 Enter the angle between the sides (in degrees): 60 Shape Perimeter Area Shape Perimeter Area ... Rectangle 23.5 34.375 Parallelogram 26.0 36.373 .************ Enter another shape (Y/N)? n Enter another shape (Y/N)? 'N Figurel (d): Parallelogram choice, angle:60 Figurel (c): Rectangle choice **** Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. .... *** Enter your choice (c, R or P): P Enter your choice (C, R or P): p Enter sidel of the parallelogram: 3 Enter sidel of the parallelogram: 3 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): -1 ERROR> angle value: -1.0 is outside range (0.18e1. Enter the angle between the sides (in degrees): 60 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): 100 Shape Perimeter Area Shape Perimeter Area Parallelogram 18.e 15.588 .**** *****. Enter another shape (Y/N)?n Parallelogram 18.0 17.727 Enter another shape (Y/N)? Y Figurel (f): Parallelogram choice, angle:-1; keep asking the user until valid angle Figurel (e): Parallelogram choice, angle:100 Your program should: a) Import required constants and function provided by Python standard library b) Use meaningful variable names, and meaningful comments to describe the solution. c) Accept menu options in lowercase or uppercase form (e.g. p and P are both valid options) d) Use appropriate messaged and a suitable proper output format to display the result (see program sample runs) e) Name the file containing your Python source code: HW2_SU21_xxxxx.py; where xxxxx is your university ID. ID should replace the string "xxxx". For example, a student with ID 75600 should submit a file cal 'HW2_SU21_75600.py'. f) Upload your Python program to Moodle.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY