diff --git a/CurrencyConverter/currencyConverter.py b/CurrencyConverter/currencyConverter.py new file mode 100644 index 0000000..e646245 --- /dev/null +++ b/CurrencyConverter/currencyConverter.py @@ -0,0 +1,23 @@ +import requests + +print("Press Enter to exit the program \n") +currency_code = input("Currency you want to convert : ").lower() +url = f'http://www.floatrates.com/daily/{currency_code}.json' +r = requests.get(url).json() +dct_currencies = {} + +if currency_code != 'usd': + dct_currencies['usd'] = float(r['usd']['rate']) +if currency_code != 'eur': + dct_currencies['eur'] = float(r['eur']['rate']) + + +while True: + received_code = input("Currency you want to convert to : ").lower() + if received_code == '': + break + amount = int(input("Enter amount : ")) + received_rate = float(r[received_code]['rate']) + dct_currencies[received_code] = received_rate + result = round(amount * received_rate, 2) + print(f'You received {result} {received_code.upper()}.') \ No newline at end of file diff --git a/README.md b/README.md index f4a6a30..49603be 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,4 @@ This is a collection of short Python scripts to solve and automate tasks and sim 30 | [**EC2-Instance-Launcher**](https://github.com/DiptoChakrabarty/Useful-Python-scripts-collection/blob/master/EC2-launcher/ec2.py) | Python script to automatically launch ec2 instances in AWS | boto3 , botocore , python-dotenv , environmental variables 31 | [**DirectorySummarizer**](https://github.com/j0fiN/Useful-Python-scripts-collection/blob/master/DirectorySummarizer/directory_summarizer.py) | A Python script which summarizes the number of different files in a directory. It also gives out the percentage of a particular file extension you want to know. | None | 31 | [**Folder-Automater**](https://github.com/decipher07/Useful-Python-scripts-collection/blob/master/Folder-Automater/automateall.py) | A Python script which compiles all the different formats of files present in the respective folder to a new folder containing only the Specified files . | None | +32 | [**Currency Conveter**](https://github.com/sharmas1ddharth/Python-scripts-collection/blob/master/CurrencyConverter/currencyConverter.py) | A Python script which can convert currency by scraping live rates from the floatrates website. | requests |