Currency converter using Python

Related Articles

Hi, Web Programmer Today we manufacture a currency converter using Python. As we know Python is a very diverse programming language and is used by the big technology giants. Anyway, we use API facility To get the conversion rates in real time and convert the appropriate amount. So, get your API key from Here.


we need requests Module to call this API.

Type the following command to install it,

pip install requests


import requests
api_url_end = ''

def currency_convertor(currency_from,currency_to,amount):
    rate = response.json()['rates'][currency_from]
    amount_in_EUR = amount/rate
    result = amount_in_EUR*(response.json()['rates'][currency_to])


print('List of country code '+str(response.json()['rates'].keys())+'n')

convert_from = input('Currency from: ')
convert_to = input('Currency to: ')

amount_to_convert = int(input("Enter the amount to convert: "))


# follow on instagram @code_snail


First, import the requests module and then we will announce api_url_end That they have a currency API endpoint and you need to replace the YOUR_API_KEY_HERE you will receive after registering at

Before understanding currency_convertor Function, we call the endpoint of our API using requests.get() We then print the country code that the user can easily find.

We then ask the user from which currency to which currency he wants to convert and then we will ask the amount to convert it and store it convert_from, convert_to and amount_to_convert Respectively

After we called currency_convertor() Function with convert_from, convert_to and amount_to_convert Arguments.

We define a function currency_convertor Which takes 3 input arguments i.e. currency_from, currency_to, amount.

Then we will define rate As a variable that stores the base currency exchange rate. Then think amount_in_EUR Since the base currency of the data obtained is the Euro.
And finally, the result will be amount_in_EUR Multiplied by the rate of currency_to.

Must try this mini-project and share it with your friends. follow me on Instagram @code_snail

Also try,

  • Text for ASCII art using python
  • Convert any image to ASCII art in Python
  • Perform a handwritten task using Python



Please enter your comment!
Please enter your name here

Popular Articles