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