-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from Chin-may02/main
Functioning temperature converter
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |