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.")