need assistance - Modify this code to introduce a new function for the commonalities in these expressions and change the calculations to calls of that function.
There are two variables. Let’s name them coeff and pollutant. It follows, then, that the new function, which we can name contribution, will include those names as its two parameters. Accordingly, we can have this as a function header:
def contribution(coeff, pollutant):
Then, adapt the expression to the right of the = operator on one of the three lines posted above to become the body of the function. That gives us:
return math.e ** (coeff * pollutant) - 1
So, what still needs to be done is to assemble the parts of the new function, add it to your program, and replace the three lines displayed above, to make appropriate calls to the new function.
Please give it a try, and post your resulting code, so that we can continue to help.
If you are writing this as a learning exercise, it is fine, but if you
are planning to use hypotenuse() for real in a program, you should
prefer Python’s version: