Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,20 +16,37 @@ def convert_temperature(value, from_unit, to_unit):
|
|
| 16 |
elif from_unit == "Kelvin" and to_unit == "Fahrenheit":
|
| 17 |
return (value - 273.15) * 9/5 + 32
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
st.markdown("""
|
| 22 |
-
This
|
| 23 |
""")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
to_unit = st.selectbox("To:", ["Celsius", "Fahrenheit", "Kelvin"])
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
elif from_unit == "Kelvin" and to_unit == "Fahrenheit":
|
| 17 |
return (value - 273.15) * 9/5 + 32
|
| 18 |
|
| 19 |
+
# Main title
|
| 20 |
+
st.set_page_config(page_title="Temperature Converter", page_icon="🌡️")
|
| 21 |
+
st.title("🌡️ Temperature Converter")
|
| 22 |
|
| 23 |
st.markdown("""
|
| 24 |
+
This application allows you to convert temperatures between Celsius, Fahrenheit, and Kelvin.
|
| 25 |
""")
|
| 26 |
|
| 27 |
+
# Sidebar for input
|
| 28 |
+
st.sidebar.header("Input Parameters")
|
| 29 |
+
temperature = st.sidebar.number_input("Enter the temperature value:", format="%.2f", help="Enter the temperature you want to convert.")
|
| 30 |
+
from_unit = st.sidebar.selectbox("From Unit:", ["Celsius", "Fahrenheit", "Kelvin"], help="Select the unit of the input temperature.")
|
| 31 |
+
to_unit = st.sidebar.selectbox("To Unit:", ["Celsius", "Fahrenheit", "Kelvin"], help="Select the unit to convert the temperature to.")
|
| 32 |
+
convert_button = st.sidebar.button("Convert")
|
| 33 |
|
| 34 |
+
# Columns for displaying results
|
| 35 |
+
col1, col2 = st.columns(2)
|
|
|
|
| 36 |
|
| 37 |
+
with col1:
|
| 38 |
+
st.image("https://via.placeholder.com/300x150.png?text=Temperature+Converter", use_column_width=True)
|
| 39 |
+
|
| 40 |
+
with col2:
|
| 41 |
+
st.subheader("Conversion Result")
|
| 42 |
+
if convert_button:
|
| 43 |
+
result = convert_temperature(temperature, from_unit, to_unit)
|
| 44 |
+
st.success(f"{temperature:.2f} {from_unit} = {result:.2f} {to_unit}")
|
| 45 |
+
else:
|
| 46 |
+
st.info("Enter the details and click Convert to see the result.")
|
| 47 |
+
|
| 48 |
+
# Footer
|
| 49 |
+
st.markdown("""
|
| 50 |
+
---
|
| 51 |
+
Made with ❤️ using [Streamlit](https://streamlit.io)
|
| 52 |
+
""")
|