Advertisement
renix1

resistor calculate

Jun 5th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. # coding:utf-8
  2. """ A module for tests in python fasdkofpdsa """
  3.  
  4. def mmc(*args):
  5.     def resolve(d):
  6.         total = 0
  7.         print d.items()
  8.         for key, value in d.items():
  9.             total = key * value
  10.         return total
  11.     mmcs = {}
  12.     for arg in args:
  13.         count = 0
  14.         while arg != 1:
  15.             if arg % 2 == 0:
  16.                 arg /= 2
  17.                 count += 1
  18.                 if 2 in mmcs.keys():
  19.                     mmcs[2] = count + 1
  20.                 else:
  21.                     mmcs[2] = count
  22.             else:
  23.                 arg /= 3
  24.                 count += 1
  25.                 if 3 in mmcs.keys():
  26.                     mmcs[3] = count + 1
  27.                 else:
  28.                     mmcs[3] = count
  29.     return resolve(mmcs)
  30.  
  31. def ass_serie(*args):
  32.     return int(sum(args))
  33.  
  34. def ass_par(*args):
  35.     mmc_total = mmc(*args)
  36.     ns = []
  37.     for i, arg in enumerate(args):
  38.         ns.append(mmc_total / arg)
  39.     total = (sum(ns))
  40.     return mmc_total / total if mmc_total > total else total / mmc_total
  41.  
  42. print("Associacao paralela: ", ass_par(3, 6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement