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