A currency converter is an application used to convert the value of one currency into another currency. In this article, I will take you through how to write a program to create a real-time currency converter with Python.
How To Create a Real-time Currency Converter with Python?
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:
- List all exchange rates
- BitCoin price for all currencies
- Converting the amount into BitCoins
- Get historical rates for any day since 1999
- The conversion rate for a currency (ex; USD to INR)
- Convert the amount from one currency to another. (‘USD $ 10’ to INR)
- Currency symbols
- Names of currencies
It uses ratesapi which is a free API to work with real-time and historical exchange rates published by the European Central Bank.
Real-time Currency Converter with Python
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.
Now let’s see how to write a program to create a real-time currency converter with Python:
Enter the amount: 56000
From Currency: USD
To Currency: INR
USD To INR 56000
I hope you liked this article on how to create a realtime currency converter with Python programing language. Feel free to ask your valuable questions in the comments section below.