Question: Give a function like this: def fun(x,y): return x / y; The following statement would produce an error at runtime (ie. a propgram crash): print(
Give a function like this:
def fun(x,y): return x / y;
The following statement would produce an error at runtime (ie. a "propgram crash"):
print( fun(2, 0) )
Instead of simply "crashing", show an altered version of the fun function that would return Python's None type if division-by-zero is attempted or some other error occurs in the function. (Of course, it should still return the correct answer otherwise.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
