Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def fix(boolean):
  2.   if boolean == True:
  3.     return 1
  4.   if boolean == False:
  5.     return -1
  6.  
  7. def multiple_slow(a,b):
  8.   print(f"{a} * {b} = ", end="")
  9.   accum = 0
  10.   top = max(a,b)
  11.   bot = min(a,b)
  12.   neg = [fix(bot<0), fix(top<0)]
  13.   for _ in range(abs(bot)):
  14.     accum += abs(top)
  15.   print(accum * neg[0] * neg[1])
  16.  
  17. multiple_slow(1,1)
  18. multiple_slow(2,1)
  19. multiple_slow(3,1)
  20. multiple_slow(-8,2)
  21. multiple_slow(-2,-2)
  22. multiple_slow(-0,-0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement