Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import random
  2.  
  3. myMoney = 1000
  4. #myMoneyPrint = str(myMoney)[0:2] + "." + str(myMoney)[2:]
  5. totalChange = []
  6.  
  7.  
  8. def getProductPrice():
  9.     Price = 0
  10.     rawPrice = (random.randint(100, 1000))
  11.     Price = str(rawPrice)[0:1] + "." + str(rawPrice)[1:4]
  12.     return rawPrice
  13.  
  14.  
  15. def moneyChange(prodPrice):
  16.     moneyList = [1, 2, 5, 10, 20, 50, 100, 200, 500]
  17.     moneyDict = {1: "1 Pence", 2: "2 Pence", 5: "5 Pence", 10: "10 Pence",
  18.                  20: "20 Pence", 50: "50 Pence", 100: "1 Pound", 200: "2 Pound", 500: "5 Pound"}
  19.  
  20.     prodPrice = myMoney - prodPrice
  21.     moneyList.reverse()
  22.     i = 0
  23.     while prodPrice >= 1:
  24.         while prodPrice >= moneyList[i]:
  25.             prodPrice = prodPrice - moneyList[i]
  26.             totalChange.append(moneyDict[moneyList[i]])
  27.         i += 1
  28.     return prodPrice
  29.  
  30.  
  31. def moneyConvert(money):
  32.     return
  33.  
  34.  
  35. prebalance = int(getProductPrice())
  36. balance = moneyChange(val1)
  37. print(f"Product costs: {val1}")
  38. #print(f"Your change from £{myMoneyPrint} is: {totalChange}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement