Loading...
The Op Dispatcher
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- mid, senior
Problem
Write a function that takes a list of dicts and an operation name string. Apply the named op to the 'value' field of each dict and return a new list with a 'result' key added. Support: 'double' (x*2), 'square' (x**2), 'abs' (absolute value), 'upper' (str uppercase), 'lower' (str lowercase).
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.