Holdener

Return of money

Oct 25th, 2020
881
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. moneyGiven = int(input("Give me money : \n"))
  2.  
  3. class Result:
  4.    
  5.     m200 = 0
  6.     m100 = 0
  7.     m50 = 0
  8.     m20 = 0
  9.     m10 = 0
  10.     m5 = 0
  11.     m2 = 0
  12.     m1 = 0
  13.  
  14.     def print_result(self):
  15.         print("you will need:\n200: {}\n100: {}\n50: {}\n20: {}\n10: {}\n5: {}\n2: {}\n1: {}".format(self.m200,self.m100,self.m50,self.m20,self.m10,self.m5,self.m2,self.m1 ))
  16.  
  17. result = Result()
  18.  
  19. while moneyGiven >= 200:
  20.     result.m200 += 1
  21.     moneyGiven -= 200
  22.  
  23. while moneyGiven >= 100:
  24.     result.m100 += 1
  25.     moneyGiven -= 100
  26.  
  27. while moneyGiven >= 50:
  28.     result.m50 += 1
  29.     moneyGiven -= 50
  30.  
  31. while moneyGiven >= 20:
  32.     result.m20 += 1
  33.     moneyGiven -= 20
  34.  
  35. while moneyGiven >= 10:
  36.     result.m10 += 1
  37.     moneyGiven -= 10
  38.  
  39. while moneyGiven >= 5:
  40.     result.m5 += 1
  41.     moneyGiven -= 5
  42.  
  43. while moneyGiven >= 2:
  44.     result.m2 += 1
  45.     moneyGiven -= 2
  46.  
  47. while moneyGiven >= 1:
  48.     result.m1 += 1
  49.     moneyGiven -= 1
  50.  
  51. result.print_result()
RAW Paste Data