Skip to content

Commit 8f76e21

Browse files
Merge pull request #310 from Adrija-G/main
Added New Project - Currency Converter
2 parents e9884b1 + dafae09 commit 8f76e21

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
conversion_rates = {
2+
'USD': 1.0, # US Dollar
3+
'EUR': 0.95, # Euro
4+
'GBP': 0.82, # British Pound
5+
'JPY': 148.45, # Japanese Yen
6+
'CAD': 1.37, # Canadian Dollar
7+
'AUD': 1.57, # Australian Dollar
8+
'INR': 83.22, # Indian Rupee
9+
'CNY': 7.20, # Chinese Yuan
10+
'CHF': 0.92, # Swiss Franc
11+
'NZD': 1.68, # New Zealand Dollar
12+
'SEK': 11.03, # Swedish Krona
13+
'SGD': 1.37, # Singapore Dollar
14+
'HKD': 7.83, # Hong Kong Dollar
15+
'KRW': 1348.59, # South Korean Won
16+
'BRL': 5.16, # Brazilian Real
17+
'RUB': 99.55, # Russian Ruble
18+
'TRY': 13.55, # Turkish Lira
19+
'ZAR': 19.29, # South African Rand
20+
'MXN': 17.95, # Mexican Peso
21+
'AED': 3.67 # UAE Dirham
22+
}
23+
def convert_currency(amount, from_currency, to_currency):
24+
if from_currency == to_currency:
25+
return amount
26+
27+
if from_currency in conversion_rates and to_currency in conversion_rates:
28+
converted_amount = amount / conversion_rates[from_currency] * conversion_rates[to_currency]
29+
return converted_amount
30+
else:
31+
return None
32+
33+
amount = float(input("Enter the amount to convert: "))
34+
from_currency = input("Enter the source currency (e.g., USD): ").upper()
35+
to_currency = input("Enter the target currency (e.g., EUR): ").upper()
36+
37+
result = convert_currency(amount, from_currency, to_currency)
38+
39+
if result is not None:
40+
print(f"{amount} {from_currency} is equal to {result} {to_currency}")
41+
else:
42+
print("Invalid currency codes. Please check your input.")

Currency-Converter/readme.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Currency Converter
2+
3+
## Description
4+
5+
The Currency Converter is an interactive Python program that allows users to convert between different currencies. It provides exchange rates for a variety of currencies and performs real-time currency conversions based on user input.
6+
7+
## Features
8+
9+
- Converts between multiple currencies.
10+
- Provides an easy-to-use command-line interface.
11+
12+
## Usage
13+
14+
1. Run the `Currency_Converter.py` script.
15+
2. Enter the amount to convert.
16+
3. Select the source currency (e.g., USD).
17+
4. Choose the target currency (e.g., EUR).
18+
5. The program will display the converted amount.
19+
20+
21+
This currency converter project uses fixed conversion rates for demonstration purposes. In a real-world application, it's essential to fetch up-to-date exchange rates from a reliable currency exchange API for accurate conversions.
22+
23+
## Author
24+
25+
[Adrija-G](https://github.com/Adrija-G)

0 commit comments

Comments
 (0)