Advertisement
viligen

math_operations

Jan 26th, 2022
1,063
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def math_operations(*args, **kwargs):
  2.     from collections import deque
  3.  
  4.     args = deque(args)
  5.     while args:
  6.         kwargs['a'] += args.popleft()
  7.         if args:
  8.             kwargs['s'] -= args.popleft()
  9.         else:
  10.             break
  11.         if args and args[0] != 0:
  12.             kwargs['d'] /= args.popleft()
  13.         elif args:
  14.             args.popleft()
  15.         else:
  16.             break
  17.         if args:
  18.             kwargs['m'] *= args.popleft()
  19.     return kwargs
  20.  
  21.  
  22. print(math_operations(2, 12, 0, -3, 6, -20, -11, a=1, s=7, d=33, m=15))
  23.  
  24.  
  25.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement