Problem Definition Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes selection. Let the program handle the perimeter and area calculations for circle, rectangle and paralle program should display a menu of the three shapes, and then allow the user to select one of the option program would request from the user to enter the required parameters of the corresponding geometrica point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape pr if there are more shapes to process.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

 

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
Perimeter
Area
Enter your choice (C, R or P): t
ERROR> Invalid choice: 't'
Enter another shape (Y/N)? y
Figurel (a): Invalid choice.
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Enter your choice (C, R or P): r
Enter the length of the rectangle: 5.5
Enter the width of the rectangle: 6.25
Shape
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.
Perimeter
Rectangle
Enter another shape (Y/N)? 'N
Figurel (c): Rectangle choice
Parallelogram
Radius r
2 πr
TY²
23.5
18.0
Area
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
34.375
Enter your choice (C, R or P): p
Enter sidel of the parallelogram: 3
Enter side2 of the parallelogram: 6
Enter the angle between the sides (in degrees): 100
Shape
Perimeter
Area
17.727
Width w
Length h
2(w + h)
w.h
Enter another shape (Y/N)? Y
Figure1 (e): Parallelogram choice, angle:100
Your program should:
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Shape
0<a ≤π/2: (S1 *S2)sina
π/2<a T: (S1 *S2) sin(n-a)
Enter your choice (C, R or P): c
Enter the radius of the Circle: 7
Circle
Sides S1 and S2
Angle a
2(S1 + S2)
Enter another shape (Y/N)? n
Figurel (b): Circle choice
Perimeter
44.0
Parallelogram
**************
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Enter your choice (C, R or P): P
Enter sidel of the parallelogram: 6
Enter side2 of the parallelogram: 7
Enter the angle between the sides (in degrees): 60
Shape
Area
Area
Parallelogram
**********.
153.938
Perimeter
26.0
Enter another shape (Y/N)? n
Figurel (d): Parallelogram choice, angle:60
18.0
Enter another shape (Y/N)? n
Select one of the following geometrical shapes:
C: circle.
R: Rectangle.
P: parallelogram.
Enter your choice (C, R or P): P
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.1801.
Enter the angle between the sides (in degrees): 60
Shape
Perimeter
Area
36.373
Figurel (f): Parallelogram choice, angle:-1;
15.588
keep asking the user until valid angle
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 "xxxxx". For example, a student with ID 75600 should submit a file called
'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 Perimeter Area Enter your choice (C, R or P): t ERROR> Invalid choice: 't' Enter another shape (Y/N)? y Figurel (a): Invalid choice. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): r Enter the length of the rectangle: 5.5 Enter the width of the rectangle: 6.25 Shape 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. Perimeter Rectangle Enter another shape (Y/N)? 'N Figurel (c): Rectangle choice Parallelogram Radius r 2 πr TY² 23.5 18.0 Area Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. 34.375 Enter your choice (C, R or P): p Enter sidel of the parallelogram: 3 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): 100 Shape Perimeter Area 17.727 Width w Length h 2(w + h) w.h Enter another shape (Y/N)? Y Figure1 (e): Parallelogram choice, angle:100 Your program should: Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Shape 0<a ≤π/2: (S1 *S2)sina π/2<a T: (S1 *S2) sin(n-a) Enter your choice (C, R or P): c Enter the radius of the Circle: 7 Circle Sides S1 and S2 Angle a 2(S1 + S2) Enter another shape (Y/N)? n Figurel (b): Circle choice Perimeter 44.0 Parallelogram ************** Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): P Enter sidel of the parallelogram: 6 Enter side2 of the parallelogram: 7 Enter the angle between the sides (in degrees): 60 Shape Area Area Parallelogram **********. 153.938 Perimeter 26.0 Enter another shape (Y/N)? n Figurel (d): Parallelogram choice, angle:60 18.0 Enter another shape (Y/N)? n Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): P 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.1801. Enter the angle between the sides (in degrees): 60 Shape Perimeter Area 36.373 Figurel (f): Parallelogram choice, angle:-1; 15.588 keep asking the user until valid angle 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 "xxxxx". For example, a student with ID 75600 should submit a file called 'HW2_SU21_75600.py'. f) Upload your Python program to Moodle.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education