f | def fix(n): | f | def fix(n): |
| | | |
n | def decorator(fun): | n | def dec(fun): |
| | | |
| def newfun(*args, **kwargs): | | def newfun(*args, **kwargs): |
n | args = (round(arg, n) if isinstance(arg, float) else arg for arg in args) | n | args = (round(x, n) if isinstance(x, float) else x for x in args) |
| kwargs = {key: round(val, n) if isinstance(val, float) else val for (key, val) in kwargs.items()} | | kwargs = {key: round(value, n) if isinstance(value, float) else value for (key, value) in kwargs.items()} |
| res = fun(*args, **kwargs) | | ans = fun(*args, **kwargs) |
| return round(res, n) if isinstance(res, float) else res | | return round(ans, n) if isinstance(ans, float) else ans |
| return newfun | | return newfun |
t | return decorator | t | return dec |