What will be the output of the following Python program?

def decorator(func):
    def wrapper():
        return "Hello " + func()
    return wrapper

@decorator
def message():
    return "Python"

print(message())
                        

Options

  • A. Python
  • B. Hello Python
  • C. Hello
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Hello Python

Detailed Explanation

A decorator modifies or extends a function without changing its original source code.