Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from forex_python.converter import CurrencyRates
- from forex_python.converter import CurrencyCodes
- from datetime import datetime
- cr = CurrencyRates()
- cd = CurrencyCodes()
- def converter(currency1, currency2, money):
- return cr.convert(currency1, currency2, money)
- def converter_with_data(currency1, currency2, money, date_obj):
- return cr.convert(currency1, currency2, money, date_obj)
- def get_history(history):
- for line in history:
- print(line)
- while True:
- print('Какую валюту Вы хотели бы поменять?')
- currency_from = str(input())
- while currency_from not in cr.get_rates('USD'):
- print('Кажется, Вы ошиблись. Введите валюту еще раз:')
- currency_from = str(input())
- print('Какую валюту Вы хотели бы получить?')
- currency_to = str(input())
- while currency_to not in cr.get_rates('USD'):
- print('Кажется, Вы ошиблись. Введите валюту еще раз:')
- currency_to = str(input())
- print('Сколько денег (' + cd.get_currency_name(currency_from) + ') Вы хотите поменять?')
- amount_of_money = float(input())
- print('Хотели бы Вы обменять валюту в ретроспективе?')
- print('Введите "да" или "нет":')
- yes_or_no = str(input())
- while yes_or_no != "да" and yes_or_no != "нет":
- print('Кажется, Вы ошиблись. Введите ответ еще раз:')
- yes_or_no = str(input())
- if yes_or_no == "нет":
- print('Вы получите:')
- final_sum = converter(currency_from, currency_to, amount_of_money), cd.get_symbol(currency_to)
- print(final_sum)
- elif yes_or_no == "да":
- print('Введите дату:')
- print('Год:')
- year = int(input())
- print('Месяц:')
- month = int(input())
- print('День:')
- day = int(input())
- date = datetime(year, month, day)
- print('Вы получите:')
- final_sum = converter_with_data(currency_from, currency_to, amount_of_money, date), cd.get_symbol(currency_to)
- print(final_sum)
- history = []
- history += ["Конвертировал " + str(amount_of_money) + cd.get_symbol(currency_from) + " в " + str(cd.get_symbol(currency_to))
- + " по курсу " + str(cr.get_rate(currency_from, currency_to)) + " и получил " + str(final_sum)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement