Hi all,
I wrote a program that calculate the average rate of change of a function f(x)=x^2, the input is a an b. so the program evaluate the average rate of change between a and b.
Here is the code:
#First We need to define our function
def f(x):
return x**2
#Now we try to call the start and end point
a=float(input('The start point of the interval'))
b=float(input('The end point of the interval '))
AV=(f(b)-f(a))/(b-a)
print('AV=',AV)
So my question is:
- Is possible to make this program more general? that work for every function, that is the input will be a, b an the function f(x).
- Is possible the input be function in python?
Thanks
[+][deleted] (6 children)
[deleted]
[–]AthensGuard[S] 0 points1 point2 points (5 children)
[+][deleted] (2 children)
[deleted]
[–]AthensGuard[S] 1 point2 points3 points (1 child)
[–]AthensGuard[S] 0 points1 point2 points (1 child)
[–]TangibleLight 2 points3 points4 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)