Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- myMoney = 1000
- #myMoneyPrint = str(myMoney)[0:2] + "." + str(myMoney)[2:]
- totalChange = []
- def getProductPrice():
- Price = 0
- rawPrice = (random.randint(100, 1000))
- Price = str(rawPrice)[0:1] + "." + str(rawPrice)[1:4]
- return rawPrice
- def moneyChange(prodPrice):
- moneyList = [1, 2, 5, 10, 20, 50, 100, 200, 500]
- moneyDict = {1: "1 Pence", 2: "2 Pence", 5: "5 Pence", 10: "10 Pence",
- 20: "20 Pence", 50: "50 Pence", 100: "1 Pound", 200: "2 Pound", 500: "5 Pound"}
- prodPrice = myMoney - prodPrice
- moneyList.reverse()
- i = 0
- while prodPrice >= 1:
- while prodPrice >= moneyList[i]:
- prodPrice = prodPrice - moneyList[i]
- totalChange.append(moneyDict[moneyList[i]])
- i += 1
- return prodPrice
- def moneyConvert(money):
- return
- prebalance = int(getProductPrice())
- balance = moneyChange(val1)
- print(f"Product costs: {val1}")
- #print(f"Your change from £{myMoneyPrint} is: {totalChange}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement