Question: In Python 3, write a decorator function that has the following property: 1. The name of the decorator is uppercase and takes a function as

In Python 3, write a decorator function that has the following property:

1. The name of the decorator is uppercase and takes a function as input.

2. The decorator has an inner function called wrapper with no input argument.

3. The wrapper function has two local variables: original and modified.

4. The input function argument of decorator gets assigned to the original variable inside the wrapper function and the upper case version of the input function gets assigned to the modified variable.

5. The wrapper function returns the modified variable.

6. The decorator returns the wrapper (per the usual of the inner functions in decorators)

7. Write a new function called greetings that prints Hello.

8. Decorate the greetings function with the uppercase decorator function.

9. Run the program by invoking the greetings function. Record the output and include it with your code.

10. Save the decorator uppercase as a separate Python file and import it to a new file that defines the greetings function as a decorated function that simply prints the Hello message.

11. Generate the output by invoking the greetings function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!