Challenge: Creating Function Decorators

Test your knowledge of creating simple decorators in Python.

We'll cover the following

Overview

Create a simple function decorator. Your decorator should calculate the execution time of that function that it decorates.

Requirements

We currently have a decorator function time_taken that will be used to decorate calculate_sqrt. The decorator function time_taken calculates the time taken by the decorated function to run, and the time library is used for this purpose.

  1. Implement the decorator function under time_taken where the parameter func is the function that time_taken will be used to decorate.

  2. Decorate calculate_sqrt using time_taken on line 13.

  3. Remove line 24 once the decorator is applied on line 13.

Get hands-on with 1200+ tech skills courses.