Question: In python Program Specifications: The program should approximate the area under the function f ( x ) = x 2 - 2 x + 3

In python
Program Specifications: The program should approximate the area under the function
f(x)=x2-2x +3
using either rectangles or trapezoids (the "mode"), see the figure. The program should input the left and right bounds that define the area (-1 and 2 in the example case shown in the figure) and which shape and how many of them to employ to approximate the area. The program must work for any valid combination of left and right bounds.
A modular design, the program should employ two functions, one that calculates the area of a single shape, and a second that calculates the entire area by calling the first function many times in a loop. Thus, in a hierarchy, the second function is higher than the first function.
The higher function should accept the left and right bounds, the mode, and the number of shapes as input, and return the total area under the curve from left to right bounds as output. Give the mode the default value of "Rectangle", and the number of shapes the default value of 100. Other inputs do not have a default value.
The lower function should accept the left and right bounds of the individual shape and the mode, and return the area of the shape as output. Give the mode the default value of "Rectangle". Other inputs do not have a default value.
Part 1 of the project: In the main program (i.e., not the two functions), prompt the user for the left and right bounds, the mode, and the number of shapes. Validate the mode input to make sure it is either "Rectangle" or "Trapezoid". If not, keep asking the user for one of these two modes. Send the user-inputs to the higher function, which should return the total area to the main program for printing. Test Part 1 thoroughly. Document your testing both in code and in the report.
Part 2 of the project: In the main program (i.e., not the two functions), and instead of prompting the user for inputs, fix the left and right bounds at -1 and 2, respectively. Set the mode as "Rectangle". In a loop, vary the number of shapes from 1 to 100 and observe the approximated area. Change the mode to "Trapezoid" and repeat. Thoroughly document and explain your findings.
 In python Program Specifications: The program should approximate the area under

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!