Write a decorator called timed that measures how long the wrapped function took to run and prints its name and execution time. The function's result should be returned as is, and the arguments can be anything.
~15 min by voice
How to approach it
This checks whether you understand that a decorator is a higher-order function that returns a wrapper, and whether you can write one correctly: pass through any arguments, return the result, preserve metadata with functools.wraps, choose the right clock and not lose the measurement on an exception.
The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.