Loading...
The Timing Decorator
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- mid, senior
Problem
Implement a Python decorator called timer that measures and prints the execution time of any function it wraps. The decorator should work correctly with functions that accept any number of positional and keyword arguments. Write a demo function that shows it working.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.