Advertisement
Guest User

code

a guest
Apr 8th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.88 KB | None | 0 0
  1. import ast
  2. from colorama import init
  3. from colorama import Fore, Back, Style
  4. init()
  5.  
  6. #WAIT FOR A USER'S INPUT
  7.  
  8. size = input("Please enter the appropriate size: ")
  9. print(Fore.RESET + Back.RESET + Style.RESET_ALL)
  10. cost = input("Please enter the cost per m2: ")
  11. print(Fore.RESET + Back.RESET + Style.RESET_ALL)
  12. print(Fore.GREEN + "Need Help? Type '!CHelp' for a list of currencies or '!CList' for a list of valid currencies.")
  13. print(Fore.RESET + Back.RESET + Style.RESET_ALL)
  14. currency = input("Please enter your desired currency: ")
  15.  
  16. #DEFINE ALL OF THE CURRENCY LISTS/CONVERSIONS
  17.  
  18. gbp = [1,0.806659,0.855866,0.60272] #GBP CONVERSIONS
  19. usd = [1.23968,1,1.06111,0.747172] #USD CONVERSIONS
  20. eur = [1.16826,0.942443,1,0.704138] #EUR CONVERSIONS
  21. cad = [0.601695,1.33844,1.42018,1] #CAD CONVERSIONS
  22. order = ["gbp", "usd", "eur", "cad"] #CONVERSION ORDER
  23. conversions = [gbp, usd, eur, cad] #COLLECTION OF CURRENCY LISTS
  24.  
  25. #IF THE USER REQUESTS HELP WITH CURRENCIES
  26.  
  27. while True:
  28.     if currency == "!CHelp":
  29.         print(" GBP \n USD \n EUR \n CAD")
  30.     elif currency != "!CList" and currency != "!CHelp":
  31.         break
  32.  
  33.     if currency == "!CList":
  34.         count = 0
  35.         index = 0
  36.         while count <= len(order)-1:
  37.             if count == len(order)-1 and not index == 3:
  38.                 print(" 1 " + str(order[index]).upper() + " ► " + str(order[count]).upper() + " = " + str(round(conversions[index][count], 2)))
  39.                 index = index +1
  40.                 count = 0
  41.             else:
  42.                 print(" 1 " + str(order[index]).upper() + " ► " + str(order[count]).upper() + " = " + str(round(conversions[index][count], 2)))
  43.                 count = count+1
  44.     elif currency != "!CList" and currency != "!CHelp":
  45.         break
  46.     currency = input("Please enter your desired currency: ")
  47.  
  48. #EDIT AND SPLIT THE VARIABLES/VALIDATE CURRENCY
  49.  
  50. size = int(size.split("x")[0]) * int(size.split("x")[1])
  51. currency = currency.lower()
  52. index = order.index(currency)
  53.  
  54. #CALCULATE ALL OF THE PRICES BASED ON THE FLOATS IN THE LISTS
  55.  
  56. gbpCost = float(gbp[index]) * float(cost) * float(size)
  57. usdCost = float(usd[index]) * float(cost) * float(size)
  58. eurCost = float(eur[index]) * float(cost) * float(size)
  59. cadCost = float(cad[index]) * float(cost) * float(size)
  60.  
  61. #PRINT ALL OF THE CURRENCY CONVERSIONS AND TOTAL AREA
  62.  
  63. print(Fore.GREEN + "Price in GBP:" + str(format(gbpCost, '.2f')) + Fore.RESET if currency == "gbp" else "Price in GBP:" + str(gbpCost))
  64. print(Fore.GREEN + "Price in USD:" + str(format(usdCost, '.2f')) + Fore.RESET if currency == "usd" else "Price in USD:" + str(usdCost))
  65. print(Fore.GREEN + "Price in EUR:" + str(format(eurCost, '.2f')) + Fore.RESET if currency == "eur" else "Price in EUR:" + str(eurCost))
  66. print(Fore.GREEN + "Price in CAD:" + str(format(cadCost, '.2f')) + Fore.RESET if currency == "cad" else "Price in CAD:" + str(cadCost))
  67. print("Total Area: " + str(size))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement