Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,36 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
#
|
17 |
-
st.
|
|
|
18 |
|
19 |
-
#
|
20 |
-
|
|
|
|
|
21 |
|
22 |
-
# Button to trigger translation
|
23 |
-
if st.button("Translate"):
|
24 |
-
if input_text.strip():
|
25 |
-
translated_text = translate(input_text)
|
26 |
-
st.subheader("Translated Urdu:")
|
27 |
-
st.write(translated_text)
|
28 |
-
else:
|
29 |
-
st.warning("Please enter some text to translate.")
|
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
+
# Function to convert temperatures
|
4 |
+
def convert_temperature(value, from_unit, to_unit):
|
5 |
+
if from_unit == 'Celsius':
|
6 |
+
if to_unit == 'Fahrenheit':
|
7 |
+
return (value * 9/5) + 32
|
8 |
+
elif to_unit == 'Kelvin':
|
9 |
+
return value + 273.15
|
10 |
+
elif from_unit == 'Fahrenheit':
|
11 |
+
if to_unit == 'Celsius':
|
12 |
+
return (value - 32) * 5/9
|
13 |
+
elif to_unit == 'Kelvin':
|
14 |
+
return ((value - 32) * 5/9) + 273.15
|
15 |
+
elif from_unit == 'Kelvin':
|
16 |
+
if to_unit == 'Celsius':
|
17 |
+
return value - 273.15
|
18 |
+
elif to_unit == 'Fahrenheit':
|
19 |
+
return ((value - 273.15) * 9/5) + 32
|
20 |
+
return value
|
21 |
|
22 |
+
# Streamlit app layout
|
23 |
+
st.title("Temperature Converter")
|
24 |
|
25 |
+
# Input temperature value
|
26 |
+
temp_value = st.number_input("Enter temperature value", step=0.1)
|
27 |
|
28 |
+
# Select units for conversion
|
29 |
+
from_unit = st.selectbox("From", ["Celsius", "Fahrenheit", "Kelvin"])
|
30 |
+
to_unit = st.selectbox("To", ["Celsius", "Fahrenheit", "Kelvin"])
|
31 |
|
32 |
+
# Convert button
|
33 |
+
if st.button("Convert"):
|
34 |
+
converted_value = convert_temperature(temp_value, from_unit, to_unit)
|
35 |
+
st.write(f"{temp_value} {from_unit} is equal to {converted_value:.2f} {to_unit}")
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|