Python program to convert U.S dollars to Indian Rupees.
This Guide contains about conversion of dollar to rupees,forex_python and some methods in forex_python
Table of Contents
Forex_python
Installation of forex_python
Methods from Forex_python
get_rate():
convert():
get_symbol():
get_currency_name():
Python Code
Output:
Forex_python
Forex Python is a package that supports free foreign exchange rates and currency conversion.
Forex_python contains list of all currency rates. Converting amount to BitCoins. It has all historical rates for any day since 1999.
It provides Conversion rate for one currency(ex; USD to INR).
It Converts amount from one currency to another.
It also provides Currency symbols and Currency names.
Installation of forex_python
The recommended way to install forex_python is enter the following command in notebook or command prompt or terminals
$ pip install forex-python
Methods from Forex_python
get_rate():
This method is used to give conversion rate from USD to INR
convert():
This method is used to Convert amount from USD to INR or between any currencies
example:c.convert('USD', 'INR', 10) # convert('USD', 'INR', 10)
674.73
get_symbol():
This method is used to Get Currency symbol Using currency code
example: c.get_symbol('GBP')
£
get_currency_name():
This method is used to Get Currency Name using currency code
example:c.get_currency_name('INR')
u'Indian rupee'
Python Code
from forex_python.converter import CurrencyRates
c = CurrencyRates()
dollar=c.get_rate('USD', 'INR')
inp=float(input("enter Dollars!!! :"))
inr=inp*dollar
print("Currency in Rupees :",round(inr,2))
Output:
enter Dollars!!! :15
Currency in Rupees : 1125.33
0 Comments
Post a Comment