Spaces:
Sleeping
Sleeping
File size: 755 Bytes
8ff8d52 |
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 |
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()
|