Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
def celsius_to_fahrenheit(celsius):
|
| 4 |
+
return (celsius * 9/5) + 32
|
| 5 |
+
|
| 6 |
+
def fahrenheit_to_celsius(fahrenheit):
|
| 7 |
+
return (fahrenheit - 32) * 5/9
|
| 8 |
+
|
| 9 |
+
st.title("Temperature Conversion App")
|
| 10 |
+
st.write("Convert temperatures between Celsius and Fahrenheit.")
|
| 11 |
+
|
| 12 |
+
# User input
|
| 13 |
+
conversion_type = st.radio("Select conversion type:", ("Celsius to Fahrenheit", "Fahrenheit to Celsius"))
|
| 14 |
+
|
| 15 |
+
temperature_input = st.number_input("Enter the temperature value:", format="%.2f")
|
| 16 |
+
|
| 17 |
+
# Perform conversion
|
| 18 |
+
if conversion_type == "Celsius to Fahrenheit":
|
| 19 |
+
converted_temp = celsius_to_fahrenheit(temperature_input)
|
| 20 |
+
st.write(f"{temperature_input}°C is equal to {converted_temp:.2f}°F.")
|
| 21 |
+
else:
|
| 22 |
+
converted_temp = fahrenheit_to_celsius(temperature_input)
|
| 23 |
+
st.write(f"{temperature_input}°F is equal to {converted_temp:.2f}°C.")
|