f | def fix(n): | f | def fix(n): |
| | | |
n | def dec(func): | n | def decorator(fun): |
| | | |
n | def new_func(*args, **kwargs): | n | def newfun(*args, **kwargs): |
| new_args = [] | | newargs = [] |
| for arg in args: | | for item in args: |
| if type(arg) == float: | | if type(item) == float: |
| new_args.append(round(arg, n)) | | newargs.append(round(item, n)) |
| else: | | else: |
n | new_args.append(arg) | n | newargs.append(item) |
| new_kwargs = dict() | | newkwargs = {} |
| for (name, arg) in kwargs.items(): | | for (key, item) in kwargs.items(): |
| if type(arg) == float: | | if type(item) == float: |
| new_kwargs[name] = round(arg, n) | | newkwargs[key] = round(item, n) |
| else: | | else: |
n | new_kwargs[name] = arg | n | newkwargs[key] = item |
| value = func(*new_args, **new_kwargs) | | result = fun(*newargs, **newkwargs) |
| if type(value) == float: | | if type(result) == float: |
| return round(value, n) | | return round(result, n) |
| else: | | else: |
t | return value | t | return result |
| return new_func | | return newfun |
| return dec | | return decorator |