Aikihack

Curency converter

May 24th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. rates = {'BGN': 1.0, 'USD': 1.79549, 'EUR': 1.95583, 'GBP': 2.53405}
  2. inputSum = float(input())
  3. currIn = input()
  4. currOut = input()
  5.  
  6.  
  7. def new_currency(curr_code):
  8.     print("Currency rate for {} unavailable! \n To Add new rate type 'YES' \n".format(curr_code))
  9.     answer = input()
  10.  
  11.     if answer == 'YES':
  12.         print("Add rate for {} : \n".format(curr_code))
  13.         new_rate = float(input())
  14.         new_record = {curr_code: new_rate}
  15.         rates[curr_code] = new_rate
  16.     pass
  17.  
  18. if rates.get(currIn) is None:
  19.     new_currency(currIn)
  20.  
  21. if rates.get(currOut) is None:
  22.     new_currency(currOut)
  23.  
  24. result = inputSum * rates.get(currIn) / rates.get(currOut)
  25. print("{:10.2f}".format(result) + " " + currOut)
Advertisement
Add Comment
Please, Sign In to add comment