Илья Федоров, 617 группа EvalFormulae 8138 | Панферов Виктор EvalFormulae 8535 | ||||
---|---|---|---|---|---|
f | 1 | import re | f | 1 | import re |
2 | 2 | ||||
3 | def evalform(formula, *args): | 3 | def evalform(formula, *args): | ||
t | 4 | vars = sorted(set(re.findall('\\b[a-zA-Z_]\\w*\\b', formula))) | t | 4 | vars = sorted(set(re.findall('[a-z]\\w*', formula))) |
5 | var_dict = {k: v for k, v in zip(vars, args)} | 5 | vals = {k: v for k, v in zip(vars, args)} | ||
6 | return eval(formula, {}, var_dict) | 6 | return eval(formula, {}, vals) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|