Advertisement

Real-time Currency Converter with Python

 

Real-time Currency Converter with Python



A currency converter is an application used to convert the value of one currency into another currency.

To convert one currency to another, we need to write a program to accept user input where the user will enter the amount of money, and then the user has to choose the type of currency the user wants to check the value of.


Then our program should just display the result by calculating the converted amount as the output. A good currency converter application should show the converted amount in real-time, which will only be possible if our program is working on real-time conversion rates.

To use real-time exchange rates, we can use the forex-python library which is used as a free tool in Python to work with exchange rates and currency conversion.


Features of Forex-Python Library:

Some of the important features provided by this library are:

  1. List all exchange rates
  2. BitCoin price for all currencies
  3. Converting the amount into BitCoins
  4. Get historical rates for any day since 1999
  5. The conversion rate for a currency (ex; USD to INR)
  6. Convert the amount from one currency to another. (‘USD $ 10’ to INR)
  7. Currency symbols
  8. Names of currencies
To create a realtime currency converter with Python., we first need to install the forex-python library which can be easily installed by using the pip command; pip install forex-python.

from forex_python.converter import CurrencyRates
c = CurrencyRates()
amount = int(input("Enter the amount: "))
from_currency = input("From Currency: ").upper()
to_currency = input("To Currency: ").upper()
print(from_currency, " To ", to_currency, amount)
result = c.convert(from_currency, to_currency, amount)
print(result)


Output:

Enter the amount: 56000
From Currency: USD
To Currency: INR
USD To INR 56000
4083923.247964




Post a Comment

0 Comments