add(a, b), subtract(a, b), multiply(a, b), divide(a, b), plus a function calculate(op, a, b) that looks up op (one of the strings "add", "subtract", "multiply", "divide") in a dict mapping operation names to functions and calls the matching function with a and b. If op is not a recognized key, return the string "Unknown operation".calculate("multiply", 4, 5)20
Looks up multiply in the dispatch table and calls multiply(4, 5).
calculate("modulo", 4, 5)Unknown operation
modulo is not a key in the dispatch table.
Build a dict like {"add": add, "subtract": subtract, ...} — function names without parentheses are references to the functions themselves.
Use dict.get(op) to look up safely, then check whether the result is None.