DataDriven
LearnPracticeInterviewDiscussDailyJobs

Execution Timer Wrapper

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
L6

Problem

Implement make_timed(fn) that returns a wrapper which invokes fn with any positional and keyword args, measures elapsed seconds, and returns fn's return value unchanged (timing is not verified by tests). Also implement run_timed(fn, args=(), kwargs=None): given fn as a lambda source string, args list, and kwargs dict, eval the source into a callable, wrap it with make_timed, invoke it with the given args/kwargs, and return the result.

Summary

Function wrapped with a timer. Duration captured on exit.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons