└── Main /Main: -------------------------------------------------------------------------------- 1 | from forex_python.converter import CurrencyRates 2 | 3 | def convert_currency(amount, from_currency, to_currency): 4 | c = CurrencyRates() 5 | rate = c.get_rate(from_currency, to_currency) 6 | converted_amount = amount * rate 7 | print(f"{amount} {from_currency} = {converted_amount:.2f} {to_currency}") 8 | 9 | if __name__ == "__main__": 10 | amount = float(input("Enter amount: ")) 11 | from_currency = input("Enter base currency (e.g., USD): ").upper() 12 | to_currency = input("Enter target currency (e.g., EUR): ").upper() 13 | convert_currency(amount, from_currency, to_currency) 14 | --------------------------------------------------------------------------------