Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. In the code shown below, which function is the decorator?

    def mk(x):
        def mk1():
            print("Decorated")
            x()
        return mk1
    def mk2():
        print("Ordinary")
    p = mk(mk2)
    p()
  2. A.
    p()
    B.
    mk()
    C.
    mk1()
    D.
    mk2()

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    In the code shown above, the function mk() is the decorator. The function which is getting decorated is mk2(). The return function is given the name p().


Be The First To Comment