diff --git a/Beginner_Projects/Temperature/README.md b/Beginner_Projects/Temperature/README.md new file mode 100644 index 0000000000..72658639de --- /dev/null +++ b/Beginner_Projects/Temperature/README.md @@ -0,0 +1,27 @@ +Temperature Converter +🎯 Goal +The goal of this project is to create a simple temperature conversion tool using Streamlit. + +🧵 Dataset +N/A + +🧾 Description +This project is a Temperature Conversion Tool where users can convert temperatures between Celsius, Fahrenheit, and Kelvin. It implements fundamental programming concepts in Python and provides an engaging, interactive experience where users can input a temperature and receive immediate feedback on its conversions. + +🧮 What I had done! +Built a simple Streamlit interface for users to input a temperature value and select the unit for conversion. +The tool converts the input temperature to the other two units (Celsius, Fahrenheit, and Kelvin) and displays the results immediately. +Error handling is implemented to manage invalid inputs gracefully, ensuring a smooth user experience. +🚀 Models Implemented +N/A + +📚 Libraries Needed +Streamlit - For building the user interface. +📊 Exploratory Data Analysis Results +N/A + +📈 Performance of the Models based on the Accuracy Scores +N/A + +📢 Conclusion +In conclusion, this Temperature Conversion Tool project demonstrates fundamental programming concepts such as user input handling, real-time data conversion, and error management in Python. It provides an engaging, interactive experience where users can convert temperatures between different scales, offering immediate feedback. The code is simple yet effective, making it a great learning project for beginner developers looking to strengthen their understanding of basic programming logic. \ No newline at end of file diff --git a/Beginner_Projects/Temperature/Temp.py b/Beginner_Projects/Temperature/Temp.py new file mode 100644 index 0000000000..c36d16afc6 --- /dev/null +++ b/Beginner_Projects/Temperature/Temp.py @@ -0,0 +1,42 @@ +import streamlit as st + +# Conversion functions +def celsius_to_fahrenheit(c): + return (c * 9/5) + 32 + +def celsius_to_kelvin(c): + return c + 273.15 + +def fahrenheit_to_celsius(f): + return (f - 32) * 5/9 + +def fahrenheit_to_kelvin(f): + return celsius_to_kelvin(fahrenheit_to_celsius(f)) + +def kelvin_to_celsius(k): + return k - 273.15 + +def kelvin_to_fahrenheit(k): + return celsius_to_fahrenheit(kelvin_to_celsius(k)) + +# Streamlit app +st.title("Temperature Converter") + +# Input widgets +unit = st.selectbox("Select Unit:", ['Celsius', 'Fahrenheit', 'Kelvin']) +temp = st.number_input("Temperature:", value=0.0) + +# Convert button +if st.button("Convert"): + if unit == 'Celsius': + fahrenheit = celsius_to_fahrenheit(temp) + kelvin = celsius_to_kelvin(temp) + st.success(f"{temp:.2f} °C = {fahrenheit:.2f} °F = {kelvin:.2f} K") + elif unit == 'Fahrenheit': + celsius = fahrenheit_to_celsius(temp) + kelvin = fahrenheit_to_kelvin(temp) + st.success(f"{temp:.2f} °F = {celsius:.2f} °C = {kelvin:.2f} K") + elif unit == 'Kelvin': + celsius = kelvin_to_celsius(temp) + fahrenheit = kelvin_to_fahrenheit(temp) + st.success(f"{temp:.2f} K = {celsius:.2f} °C = {fahrenheit:.2f} °F") \ No newline at end of file