What is the output of the following code? def smart_divide(func): def wrapper(*args): a, b = args if b == 0: print('oops! cannot divide') return return func(*args) return wrapper @smart_divide def divide(a, b): return a / b print(divide.__name__) print(divide(4, 16)) print(divide(8,0))

Questions & AnswersCategory: Programming LanguageWhat is the output of the following code? def smart_divide(func): def wrapper(*args): a, b = args if b == 0: print('oops! cannot divide') return return func(*args) return wrapper @smart_divide def divide(a, b): return a / b print(divide.__name__) print(divide(4, 16)) print(divide(8,0))
Adam asked 3 years ago

What is the output of the following code?

def smart_divide(func):

    def wrapper(*args):

        a, b = args

        if b == 0:

            print('oops! cannot divide')

            return

        return func(*args)

    return wrapper

@smart_divide

def divide(a, b):

    return a / b

print(divide.__name__)

print(divide(4, 16))

print(divide(8,0))

a. smart_divide
0.25
oops! cannot divide
b. wrapper
0.25
oops! cannot divide
c. smart_divide
0.25
oops! cannot divide
None
d. wrapper
0.25
oops! cannot divide
None