Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago