Ибрагим Атабеков, 428 группа EvalFormulae 8525 | Горбачёв Алексей Валериевич, 515 группа EvalFormulae 7643 | ||||
---|---|---|---|---|---|
f | 1 | import re | f | 1 | import re |
2 | 2 | ||||
3 | def evalform(formula, *args): | 3 | def evalform(formula, *args): | ||
t | 4 | variables = sorted(set(re.findall('[a-zA-Z]+', formula))) | t | 4 | names = sorted(set(re.findall('[a-zA-Z]+', formula))) |
5 | var_to_value_map = dict(zip(variables, args)) | 5 | variables = dict(zip(names, args)) | ||
6 | return eval(formula, {}, var_to_value_map) | 6 | return eval(formula, variables) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|