Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Title and Description
|
| 4 |
+
st.title("Temperature Conversion App")
|
| 5 |
+
st.markdown("Convert temperatures between Celsius and Fahrenheit.")
|
| 6 |
+
|
| 7 |
+
# Input Temperature
|
| 8 |
+
temp_input = st.number_input("Enter the temperature to convert:", format="%.2f")
|
| 9 |
+
|
| 10 |
+
# Conversion Option
|
| 11 |
+
conversion_type = st.radio(
|
| 12 |
+
"Select conversion type:",
|
| 13 |
+
("Celsius to Fahrenheit", "Fahrenheit to Celsius"),
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
# Conversion Logic
|
| 17 |
+
if conversion_type == "Celsius to Fahrenheit":
|
| 18 |
+
converted_temp = (temp_input * 9/5) + 32
|
| 19 |
+
st.write(f"{temp_input:.2f}°C is equal to {converted_temp:.2f}°F.")
|
| 20 |
+
elif conversion_type == "Fahrenheit to Celsius":
|
| 21 |
+
converted_temp = (temp_input - 32) * 5/9
|
| 22 |
+
st.write(f"{temp_input:.2f}°F is equal to {converted_temp:.2f}°C.")
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
streamlit
|