alternative is the essence of the power of mathematicswhile the first alternative is the source of much confusion about mathematicsrb implementation with functions for the integral /dx computed by the formula ( we want the corresponding python function trapezoid to take any aband as input and return the approximation to the integral we write python function trapezoidal in file trapezoidal py as close as possible to the formula ( )making sure variable names correspond to the mathematical notationdef trapezoidal(fabn) float( - )/ result * ( * (bfor in range( )result + ( *hresult * return result solving our specific problem in session just having the trapezoidal function as the only content of file trapezoidal py automatically makes that file module that we can import and test in an interactive sessionfrom trapezoidal import trapezoidal from math import exp lambda *( ** )*exp( ** numerical trapezoidal( nnumerical let us compute the exact expression and the error in the approximationv lambda texp( ** exact ( ( exact numerical - is this error convincingwe can try larger nnumerical trapezoidal( = exact numerical - - fortunatelymany more trapezoids give much smaller error solving our specific problem in program instead of computing our special problem in an interactive sessionwe can do it in program as alwaysa chunk of code doing particular thing is best isolated as function even if we do not see any future reason to call the function several times and even if we have no need for arguments to parameterize what goes on inside the function in the present case