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.
Implement the decorator function under
time_taken
where the parameterfunc
is the function thattime_taken
will be used to decorate.Decorate
calculate_sqrt
usingtime_taken
on line 13.Remove line 24 once the decorator is applied on line 13.
Get hands-on with 1400+ tech skills courses.