Programming Languages Python Subjective
Sep 30, 2025

Write a Python decorator that measures execution time of a function.

Detailed Explanation
import time\ndef timer(func):\n def wrapper(*args, **kwargs):\n start = time.time()\n result = func(*args, **kwargs)\n end = time.time()\n print(f"{func.__name__} took {end-start:.4f} seconds")\n return result\n return wrapper
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback