Question: Python Exercise Rectangle Objectives: Practice function decomposition. You are asked to write a program to compute area and perimeter of a rectangle, given its width
Exercise Rectangle Objectives: Practice function decomposition. You are asked to write a program to compute area and perimeter of a rectangle, given its width and height, and display the results on screen. You are advised to decompose this larger task into three smaller subtasks. The first subtask is to obtain the width and height of a rectangle from users. The second subtask is to calculate the area of a rectangle with its width and height as inputs. The third subtask is to calculate the perimeter of a rectangle with its width and height as inputs. You are going to define three functions, get inputs, rectArea, and rectPerimeter, to implement these three subtasks. Besides, you have to define a main function to dispatch subtasks to appropriate functions, collect the computed area and perimeter, and then display a report on screen to users. In other words, you need to define four functions in total. Finally, don't forget to make the program run by invoking the main function with the following statement: if namemain_": main() An example interactive session is illustrated as follows where users' inputs are underlined: Please enter the width of the rectangle (ft):6 Please enter the height of the rectangle (ft): 4 A rectange with dimensions 6.0 ft by 4.0, ft Has perimeter 20.0 ft and area 24.0 sq. ft
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
