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

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!