Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- moneyGiven = int(input("Give me money : \n"))
- class Result:
- m200 = 0
- m100 = 0
- m50 = 0
- m20 = 0
- m10 = 0
- m5 = 0
- m2 = 0
- m1 = 0
- def print_result(self):
- 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 ))
- result = Result()
- while moneyGiven >= 200:
- result.m200 += 1
- moneyGiven -= 200
- while moneyGiven >= 100:
- result.m100 += 1
- moneyGiven -= 100
- while moneyGiven >= 50:
- result.m50 += 1
- moneyGiven -= 50
- while moneyGiven >= 20:
- result.m20 += 1
- moneyGiven -= 20
- while moneyGiven >= 10:
- result.m10 += 1
- moneyGiven -= 10
- while moneyGiven >= 5:
- result.m5 += 1
- moneyGiven -= 5
- while moneyGiven >= 2:
- result.m2 += 1
- moneyGiven -= 2
- while moneyGiven >= 1:
- result.m1 += 1
- moneyGiven -= 1
- result.print_result()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement