File size: 1,245 Bytes
e9ce736
 
b283839
 
 
 
 
 
 
 
e9ce736
b283839
 
 
364b861
b283839
e9ce736
b283839
e9ce736
 
364b861
 
 
 
 
b283839
 
e9ce736
 
 
b283839
 
25dd8a6
b283839
25dd8a6
b283839
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
import streamlit as st

# Static exchange rates (approximate)
exchange_rates = {
    "USD": 1,
    "EUR": 0.9,
    "GBP": 0.8,
    "JPY": 140,
    "PKR": 300
}

def convert_currency(amount, from_currency, to_currency):
    if from_currency == to_currency:
        return amount
    else:
        return amount * (exchange_rates[to_currency] / exchange_rates[from_currency])

st.title("Currency Converter")

# User input for amount and currencies
with st.container():
    col1, col2 = st.columns(2)
    with col1:
        amount = st.number_input("Enter amount:", min_value=0.01, step=0.01)
    with col2:
        from_currency = st.selectbox("From Currency:", options=exchange_rates.keys())
        to_currency = st.selectbox("To Currency:", options=exchange_rates.keys())

# Button to trigger conversion
if st.button("Convert"):
    converted_amount = convert_currency(amount, from_currency, to_currency)
    st.success(f"{amount} {from_currency} is equal to {converted_amount:.2f} {to_currency}")

# Add a disclaimer about the limitations of static exchange rates
st.markdown("---")
st.write("**Note:** This converter uses static exchange rates. For accurate and real-time conversions, please use a service that accesses live exchange rates.")