school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

shops.py (653B)


      1 total = int(input("how much does it cost: "))
      2 totalPayed = int(input("how much did you get: "))
      3 
      4 if totalPayed < total:
      5 	print(f"{totalPayed:.2f} is not enough to pay for {total:.2f}")
      6 	exit()
      7 
      8 totalChange = totalPayed - total
      9 changeToGive = []
     10 while totalChange != 0:
     11 	if totalChange >= 10:
     12 		totalChange = totalChange - 10
     13 		changeToGive.append(10)
     14 	elif totalChange >= 5:
     15 		totalChange = totalChange - 5
     16 		changeToGive.append(5)
     17 	elif totalChange >= 2:
     18 		totalChange = totalChange - 2
     19 		changeToGive.append(2)
     20 	elif totalChange >= 1:
     21 		totalChange = totalChange - 1
     22 		changeToGive.append(1)
     23 
     24 print(f"you need to give the customer : {changeToGive}")
     25