diff options
Diffstat (limited to 'comp/work/2/shops.py')
-rwxr-xr-x | comp/work/2/shops.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/comp/work/2/shops.py b/comp/work/2/shops.py new file mode 100755 index 0000000..57cff25 --- /dev/null +++ b/comp/work/2/shops.py @@ -0,0 +1,25 @@ +total = int(input("how much does it cost: ")) +totalPayed = int(input("how much did you get: ")) + +if totalPayed < total: + print(f"{totalPayed:.2f} is not enough to pay for {total:.2f}") + exit() + +totalChange = totalPayed - total +changeToGive = [] +while totalChange != 0: + if totalChange >= 10: + totalChange = totalChange - 10 + changeToGive.append(10) + elif totalChange >= 5: + totalChange = totalChange - 5 + changeToGive.append(5) + elif totalChange >= 2: + totalChange = totalChange - 2 + changeToGive.append(2) + elif totalChange >= 1: + totalChange = totalChange - 1 + changeToGive.append(1) + +print(f"you need to give the customer : {changeToGive}") + |