Kamran Zulfiqar
Update app.py
8ff8d52 verified
raw
history blame
755 Bytes
import streamlit as st
# App title
st.title("🌡️ Temperature Converter")
# Temperature unit selection
conversion_type = st.radio(
"Select Conversion Type:",
("Celsius to Fahrenheit", "Fahrenheit to Celsius")
)
# Temperature input using a slider
if conversion_type == "Celsius to Fahrenheit":
temp_c = st.slider("Select Temperature in °C:", -100.0, 100.0, 0.0)
temp_f = (temp_c * 9/5) + 32
st.metric("Converted Temperature (°F)", f"{temp_f:.2f} °F")
else:
temp_f = st.slider("Select Temperature in °F:", -148.0, 212.0, 32.0)
temp_c = (temp_f - 32) * 5/9
st.metric("Converted Temperature (°C)", f"{temp_c:.2f} °C")
# Optional clear button (refreshes app)
if st.button("🔄 Reset"):
st.experimental_rerun()