Question: Why would you use a decorator?

  1. A decorator is similar to a class and should be used if you are doing functional programming instead of object oriented programming.
  2. A decorator is a visual indicator to someone reading your code that a portion of your code is critical and should not be changed.
  3. You use the decorator to alter the functionality of a function without having to modify the functions code.
  4. An import statement is preceded by a decorator, python knows to import the most recent version of whatever package or library is being imported.

Answer: The correct answer of the above question is Option C:You use the decorator to alter the functionality of a function without having to modify the functions code.