From 99b5af201cfb400a9210ebed1f49c89a34edf1cb Mon Sep 17 00:00:00 2001 From: Sweta Negi Date: Tue, 28 Oct 2025 19:53:31 +0530 Subject: [PATCH] Add currency converter functionality Implement a currency converter that converts between USD, EUR, and INR. --- currency_convertor.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 currency_convertor.py diff --git a/currency_convertor.py b/currency_convertor.py new file mode 100644 index 0000000..fce6ae6 --- /dev/null +++ b/currency_convertor.py @@ -0,0 +1,19 @@ +rates = { + "USD": 83.2, # 1 USD = 83.2 INR + "EUR": 90.5, # 1 EUR = 90.5 INR + "INR": 1 +} + +def convert_currency(amount, from_currency, to_currency): + in_inr = amount * rates[from_currency] + return in_inr / rates[to_currency] + +amount = float(input("Enter amount: ")) +from_curr = input("From currency (USD/EUR/INR): ").upper() +to_curr = input("To currency (USD/EUR/INR): ").upper() + +if from_curr in rates and to_curr in rates: + result = convert_currency(amount, from_curr, to_curr) + print(f"{amount} {from_curr} = {result:.2f} {to_curr}") +else: + print("Invalid currency input.")