RosettaCodeData/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py

6 lines
119 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
>>> def eval_with_x(code, a, b):
return eval(code, {'x':b}) - eval(code, {'x':a})
>>> eval_with_x('2 ** x', 3, 5)
24