File size: 4,176 Bytes
8a13477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import streamlit as st

# Title of the app
st.title("🌍 Currency Converter App")

# Static exchange rates (base currency: USD)
# Note: These rates are for demonstration purposes only and may not reflect real-world values.
exchange_rates = {
    "PKR": 279.50,  # Pakistani Rupee
    "USD": 1.0,     # US Dollar
    "CNY": 7.20,    # Chinese Yuan
    "INR": 83.00,   # Indian Rupee
    "RUB": 92.00,   # Russian Ruble
    "JPY": 149.00,  # Japanese Yen
    "EUR": 0.93,    # Euro (Germany, France, Italy, etc.)
    "GBP": 0.80,    # British Pound
    "BRL": 5.00,    # Brazilian Real
    "CAD": 1.35,    # Canadian Dollar
    "AUD": 1.55,    # Australian Dollar
    "KRW": 1300.00, # South Korean Won
    "MXN": 18.00,   # Mexican Peso
    "IDR": 15500.00,# Indonesian Rupiah
    "TRY": 30.00,   # Turkish Lira
    "SAR": 3.75,    # Saudi Riyal
    "CHF": 0.90,    # Swiss Franc
    "ARS": 800.00,  # Argentine Peso
    "ZAR": 19.00,   # South African Rand
    "EGP": 30.00,   # Egyptian Pound
    "THB": 36.00,   # Thai Baht
    "SEK": 10.50,   # Swedish Krona
    "NOK": 10.00,   # Norwegian Krone
    "PLN": 4.20,    # Polish Złoty
    "MYR": 4.70,    # Malaysian Ringgit
    "SGD": 1.35,    # Singapore Dollar
    "PHP": 56.00,   # Philippine Peso
    "VND": 24000.00,# Vietnamese Dong
    "DKK": 6.90,    # Danish Krone
    "IRR": 42000.00,# Iranian Rial
    "IQD": 1300.00, # Iraqi Dinar
    "ILS": 3.90,    # Israeli Shekel
    "AED": 3.67,    # UAE Dirham
    "NGN": 900.00,  # Nigerian Naira
    "KES": 150.00,  # Kenyan Shilling
    "COP": 4000.00, # Colombian Peso
    "CLP": 900.00,  # Chilean Peso
    "PEN": 3.80,    # Peruvian Sol
    "NZD": 1.65,    # New Zealand Dollar
    "BDT": 110.00,  # Bangladeshi Taka
    "LKR": 320.00,  # Sri Lankan Rupee
    "NPR": 130.00,  # Nepalese Rupee
    "AFN": 85.00,   # Afghan Afghani
    "QAR": 3.64,    # Qatari Riyal
}

# List of countries and their currency codes
country_currencies = {
    "Pakistan": "PKR",
    "United States": "USD",
    "China": "CNY",
    "India": "INR",
    "Russia": "RUB",
    "Japan": "JPY",
    "Germany": "EUR",
    "United Kingdom": "GBP",
    "France": "EUR",
    "Brazil": "BRL",
    "Canada": "CAD",
    "Australia": "AUD",
    "Italy": "EUR",
    "South Korea": "KRW",
    "Spain": "EUR",
    "Mexico": "MXN",
    "Indonesia": "IDR",
    "Turkey": "TRY",
    "Saudi Arabia": "SAR",
    "Switzerland": "CHF",
    "Netherlands": "EUR",
    "Argentina": "ARS",
    "South Africa": "ZAR",
    "Egypt": "EGP",
    "Thailand": "THB",
    "Sweden": "SEK",
    "Norway": "NOK",
    "Poland": "PLN",
    "Malaysia": "MYR",
    "Singapore": "SGD",
    "Philippines": "PHP",
    "Vietnam": "VND",
    "Greece": "EUR",
    "Portugal": "EUR",
    "Denmark": "DKK",
    "Iran": "IRR",
    "Iraq": "IQD",
    "Israel": "ILS",
    "UAE (United Arab Emirates)": "AED",
    "Nigeria": "NGN",
    "Kenya": "KES",
    "Colombia": "COP",
    "Chile": "CLP",
    "Peru": "PEN",
    "New Zealand": "NZD",
    "Bangladesh": "BDT",
    "Sri Lanka": "LKR",
    "Nepal": "NPR",
    "Afghanistan": "AFN",
    "Qatar": "QAR",
}

# Function to convert currency
def convert_currency(amount, from_currency, to_currency):
    if from_currency == to_currency:
        return amount
    # Convert to USD first, then to the target currency
    amount_in_usd = amount / exchange_rates[from_currency]
    converted_amount = amount_in_usd * exchange_rates[to_currency]
    return converted_amount

# Streamlit UI
st.write("### Select Currencies and Amount")

# Dropdown for selecting source and target currencies
from_currency = st.selectbox("From Currency", list(country_currencies.values()), key="from_currency")
to_currency = st.selectbox("To Currency", list(country_currencies.values()), key="to_currency")

# Input for amount
amount = st.number_input("Amount", min_value=0.01, value=1.00, step=0.01)

# Convert button
if st.button("Convert"):
    converted_amount = convert_currency(amount, from_currency, to_currency)
    st.success(f"**{amount} {from_currency} = {converted_amount:.2f} {to_currency}**")

# Footer
st.write("---")
st.write("**Note:** Exchange rates are static and for demonstration purposes only.")