CoolFace
Apppublic

GreenTechCC/TemperatureConverter

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py33 linesDownload Raw Back to root
1import streamlit as st2 3# Title of the app4st.title("Temperature Converter")5 6# Description7st.write("This app converts temperatures between Celsius, Fahrenheit, and Kelvin.")8 9# Input field for temperature value10temp = st.number_input("Enter temperature value:", value=0)11 12# Dropdown for selecting temperature unit13unit = st.selectbox("Select the unit of the input temperature:", 14                    ['Celsius', 'Fahrenheit', 'Kelvin'])15 16# Convert button to trigger conversion17if st.button("Convert"):18    if unit == "Celsius":19        fahrenheit = (temp * 9/5) + 3220        kelvin = temp + 273.1521        st.write(f"{temp}° Celsius = {fahrenheit}° Fahrenheit")22        st.write(f"{temp}° Celsius = {kelvin} Kelvin")23    elif unit == "Fahrenheit":24        celsius = (temp - 32) * 5/925        kelvin = (temp - 32) * 5/9 + 273.1526        st.write(f"{temp}° Fahrenheit = {celsius}° Celsius")27        st.write(f"{temp}° Fahrenheit = {kelvin} Kelvin")28    elif unit == "Kelvin":29        celsius = temp - 273.1530        fahrenheit = (temp - 273.15) * 9/5 + 3231        st.write(f"{temp} Kelvin = {celsius}° Celsius")32        st.write(f"{temp} Kelvin = {fahrenheit}° Fahrenheit")33