from forex_python.converter import CurrencyRates c = CurrencyRates() amount = 100 usd_to_eur = c.convert('USD', 'EUR', amount) print(f"{amount} USD is equal to {usd_to_eur} EUR")
from forex_python.converter import CurrencyRates c = CurrencyRates() amount = 5000 jpy_to_usd = c.convert('JPY', 'USD', amount) print(f"{amount} JPY is equal to {jpy_to_usd} USD")
from forex_python.converter import CurrencyRates c = CurrencyRates() amount = 500 eur_to_gbp = c.convert('EUR', 'GBP', amount) print(f"{amount} EUR is equal to {eur_to_gbp} GBP")In the above examples, we create a CurrencyRates object, then call the convert method with the source currency, target currency and the amount to be converted. The method returns the converted currency as a float. forex_python.converter package uses the forex_python library which is used to retrieve forex rates from Oanda.