n | def fix(n: int): | n | def fix(n): |
| | | |
n | def decorator(fun): | n | def decorator(fn): |
| | | |
n | def fix_fun(*args, **kwargs): | n | def wrapper(*args, **kwargs): |
| new_args = [] | | n_arg = [] |
| for arg in args: | | for i in args: |
| if isinstance(arg, float): | | if isinstance(i, float): |
| new_args.append(round(arg, n)) | | n_arg.append(round(i, n)) |
| else: | | else: |
n | new_args.append(arg) | n | n_arg.append(i) |
| for (key, value) in kwargs.items(): | | for (j, k) in kwargs.items(): |
| if isinstance(value, float): | | if isinstance(k, float): |
| kwargs[key] = round(value, n) | | kwargs[j] = round(k, n) |
| result = fun(*new_args, **kwargs) | | res = fn(*n_arg, **kwargs) |
| if isinstance(result, float): | | if isinstance(res, float): |
| return round(result, n) | | return round(res, n) |
| else: | | else: |
t | return result | t | return res |
| return fix_fun | | return wrapper |
| return decorator | | return decorator |