Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ast
- from colorama import init
- from colorama import Fore, Back, Style
- init()
- #WAIT FOR A USER'S INPUT
- size = input("Please enter the appropriate size: ")
- print(Fore.RESET + Back.RESET + Style.RESET_ALL)
- cost = input("Please enter the cost per m2: ")
- print(Fore.RESET + Back.RESET + Style.RESET_ALL)
- print(Fore.GREEN + "Need Help? Type '!CHelp' for a list of currencies or '!CList' for a list of valid currencies.")
- print(Fore.RESET + Back.RESET + Style.RESET_ALL)
- currency = input("Please enter your desired currency: ")
- #DEFINE ALL OF THE CURRENCY LISTS/CONVERSIONS
- gbp = [1,0.806659,0.855866,0.60272] #GBP CONVERSIONS
- usd = [1.23968,1,1.06111,0.747172] #USD CONVERSIONS
- eur = [1.16826,0.942443,1,0.704138] #EUR CONVERSIONS
- cad = [0.601695,1.33844,1.42018,1] #CAD CONVERSIONS
- order = ["gbp", "usd", "eur", "cad"] #CONVERSION ORDER
- conversions = [gbp, usd, eur, cad] #COLLECTION OF CURRENCY LISTS
- #IF THE USER REQUESTS HELP WITH CURRENCIES
- while True:
- if currency == "!CHelp":
- print(" GBP \n USD \n EUR \n CAD")
- elif currency != "!CList" and currency != "!CHelp":
- break
- if currency == "!CList":
- count = 0
- index = 0
- while count <= len(order)-1:
- if count == len(order)-1 and not index == 3:
- print(" 1 " + str(order[index]).upper() + " ► " + str(order[count]).upper() + " = " + str(round(conversions[index][count], 2)))
- index = index +1
- count = 0
- else:
- print(" 1 " + str(order[index]).upper() + " ► " + str(order[count]).upper() + " = " + str(round(conversions[index][count], 2)))
- count = count+1
- elif currency != "!CList" and currency != "!CHelp":
- break
- currency = input("Please enter your desired currency: ")
- #EDIT AND SPLIT THE VARIABLES/VALIDATE CURRENCY
- size = int(size.split("x")[0]) * int(size.split("x")[1])
- currency = currency.lower()
- index = order.index(currency)
- #CALCULATE ALL OF THE PRICES BASED ON THE FLOATS IN THE LISTS
- gbpCost = float(gbp[index]) * float(cost) * float(size)
- usdCost = float(usd[index]) * float(cost) * float(size)
- eurCost = float(eur[index]) * float(cost) * float(size)
- cadCost = float(cad[index]) * float(cost) * float(size)
- #PRINT ALL OF THE CURRENCY CONVERSIONS AND TOTAL AREA
- print(Fore.GREEN + "Price in GBP:" + str(format(gbpCost, '.2f')) + Fore.RESET if currency == "gbp" else "Price in GBP:" + str(gbpCost))
- print(Fore.GREEN + "Price in USD:" + str(format(usdCost, '.2f')) + Fore.RESET if currency == "usd" else "Price in USD:" + str(usdCost))
- print(Fore.GREEN + "Price in EUR:" + str(format(eurCost, '.2f')) + Fore.RESET if currency == "eur" else "Price in EUR:" + str(eurCost))
- print(Fore.GREEN + "Price in CAD:" + str(format(cadCost, '.2f')) + Fore.RESET if currency == "cad" else "Price in CAD:" + str(cadCost))
- print("Total Area: " + str(size))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement