Skip to content

Commit

Permalink
Merge pull request #204 from Chin-may02/main
Browse files Browse the repository at this point in the history
Functioning temperature converter
  • Loading branch information
UTSAVS26 authored Oct 7, 2024
2 parents 5397982 + 6db1bdd commit 4d5e6fd
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Beginner_Projects/Temperature/README.md
Original file line number Diff line number Diff line change
@@ -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.
42 changes: 42 additions & 0 deletions Beginner_Projects/Temperature/Temp.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 4d5e6fd

Please sign in to comment.