Spaces:
Sleeping
Sleeping
Kamran Zulfiqar
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# App title
|
4 |
+
st.title("🌡️ Temperature Converter")
|
5 |
+
|
6 |
+
# Temperature unit selection
|
7 |
+
conversion_type = st.radio(
|
8 |
+
"Select Conversion Type:",
|
9 |
+
("Celsius to Fahrenheit", "Fahrenheit to Celsius")
|
10 |
+
)
|
11 |
+
|
12 |
+
# Temperature input using a slider
|
13 |
+
if conversion_type == "Celsius to Fahrenheit":
|
14 |
+
temp_c = st.slider("Select Temperature in °C:", -100.0, 100.0, 0.0)
|
15 |
+
temp_f = (temp_c * 9/5) + 32
|
16 |
+
st.metric("Converted Temperature (°F)", f"{temp_f:.2f} °F")
|
17 |
+
else:
|
18 |
+
temp_f = st.slider("Select Temperature in °F:", -148.0, 212.0, 32.0)
|
19 |
+
temp_c = (temp_f - 32) * 5/9
|
20 |
+
st.metric("Converted Temperature (°C)", f"{temp_c:.2f} °C")
|
21 |
+
|
22 |
+
# Optional clear button (refreshes app)
|
23 |
+
if st.button("🔄 Reset"):
|
24 |
+
st.experimental_rerun()
|