|
import streamlit as st |
|
|
|
|
|
st.title("🌍 Currency Converter App") |
|
|
|
|
|
|
|
exchange_rates = { |
|
"PKR": 279.50, |
|
"USD": 1.0, |
|
"CNY": 7.20, |
|
"INR": 83.00, |
|
"RUB": 92.00, |
|
"JPY": 149.00, |
|
"EUR": 0.93, |
|
"GBP": 0.80, |
|
"BRL": 5.00, |
|
"CAD": 1.35, |
|
"AUD": 1.55, |
|
"KRW": 1300.00, |
|
"MXN": 18.00, |
|
"IDR": 15500.00, |
|
"TRY": 30.00, |
|
"SAR": 3.75, |
|
"CHF": 0.90, |
|
"ARS": 800.00, |
|
"ZAR": 19.00, |
|
"EGP": 30.00, |
|
"THB": 36.00, |
|
"SEK": 10.50, |
|
"NOK": 10.00, |
|
"PLN": 4.20, |
|
"MYR": 4.70, |
|
"SGD": 1.35, |
|
"PHP": 56.00, |
|
"VND": 24000.00, |
|
"DKK": 6.90, |
|
"IRR": 42000.00, |
|
"IQD": 1300.00, |
|
"ILS": 3.90, |
|
"AED": 3.67, |
|
"NGN": 900.00, |
|
"KES": 150.00, |
|
"COP": 4000.00, |
|
"CLP": 900.00, |
|
"PEN": 3.80, |
|
"NZD": 1.65, |
|
"BDT": 110.00, |
|
"LKR": 320.00, |
|
"NPR": 130.00, |
|
"AFN": 85.00, |
|
"QAR": 3.64, |
|
} |
|
|
|
|
|
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", |
|
} |
|
|
|
|
|
def convert_currency(amount, from_currency, to_currency): |
|
if from_currency == to_currency: |
|
return amount |
|
|
|
amount_in_usd = amount / exchange_rates[from_currency] |
|
converted_amount = amount_in_usd * exchange_rates[to_currency] |
|
return converted_amount |
|
|
|
|
|
st.write("### Select Currencies and Amount") |
|
|
|
|
|
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") |
|
|
|
|
|
amount = st.number_input("Amount", min_value=0.01, value=1.00, step=0.01) |
|
|
|
|
|
if st.button("Convert"): |
|
converted_amount = convert_currency(amount, from_currency, to_currency) |
|
st.success(f"**{amount} {from_currency} = {converted_amount:.2f} {to_currency}**") |
|
|
|
|
|
st.write("---") |
|
st.write("**Note:** Exchange rates are static and for demonstration purposes only.") |