Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What is the output of the code shown below?

    def f(x):
        def f1(a, b):
            print("hello")
            if b==0:
                print("NO")
                return
            return f(a, b)
        return f1
    @f
    def f(a, b):
        return a%b
    f(4,0)
  2. A.

    hello

    NO

    B.

    hello

    Zero Division Error

    C.
    NO
    D.
    hello

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    In the code shown above, we have used a decorator in order to avoid the Zero Division Error. Hence the output of this code is: hello NO


Be The First To Comment