From dc43e647d5b883433f5a0589da42cdda8ab0338b Mon Sep 17 00:00:00 2001 From: Omprakash00724 <84080435+Omprakash00724@users.noreply.github.com> Date: Thu, 30 Oct 2025 19:12:20 +0530 Subject: [PATCH] Add temperature converter project --- Temperature_Converter/README.md | 31 ++++++++++ .../temperature_converter.py | 62 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 Temperature_Converter/README.md create mode 100644 Temperature_Converter/temperature_converter.py diff --git a/Temperature_Converter/README.md b/Temperature_Converter/README.md new file mode 100644 index 0000000..0885a92 --- /dev/null +++ b/Temperature_Converter/README.md @@ -0,0 +1,31 @@ +# 🌡️ Temperature Converter + +A simple and interactive Python program to convert temperatures between **Celsius**, **Fahrenheit**, and **Kelvin**. + +## 🚀 Features +- Convert between all major temperature units +- Clean and easy-to-use CLI interface +- Accurate conversion formulas + +## 🧩 How to Run +```bash +python temperature_converter.py +``` + +## 📖 Example +``` +🌡️ Temperature Converter +1. Celsius to Fahrenheit +2. Fahrenheit to Celsius +3. Celsius to Kelvin +4. Kelvin to Celsius +5. Fahrenheit to Kelvin +6. Kelvin to Fahrenheit +Enter choice (1–6): 1 +Enter Celsius: 25 +25°C = 77.00°F +``` + +--- + +✅ **Simple. Accurate. Handy.** diff --git a/Temperature_Converter/temperature_converter.py b/Temperature_Converter/temperature_converter.py new file mode 100644 index 0000000..105d19a --- /dev/null +++ b/Temperature_Converter/temperature_converter.py @@ -0,0 +1,62 @@ +# Temperature Converter +# Converts temperature between Celsius, Fahrenheit, and Kelvin + +def celsius_to_fahrenheit(celsius): + return (celsius * 9 / 5) + 32 + + +def fahrenheit_to_celsius(fahrenheit): + return (fahrenheit - 32) * 5 / 9 + + +def celsius_to_kelvin(celsius): + return celsius + 273.15 + + +def kelvin_to_celsius(kelvin): + return kelvin - 273.15 + + +def fahrenheit_to_kelvin(fahrenheit): + return (fahrenheit - 32) * 5 / 9 + 273.15 + + +def kelvin_to_fahrenheit(kelvin): + return (kelvin - 273.15) * 9 / 5 + 32 + + +def main(): + print("🌡️ Temperature Converter") + print("1. Celsius to Fahrenheit") + print("2. Fahrenheit to Celsius") + print("3. Celsius to Kelvin") + print("4. Kelvin to Celsius") + print("5. Fahrenheit to Kelvin") + print("6. Kelvin to Fahrenheit") + + choice = input("Enter choice (1–6): ") + + if choice == "1": + c = float(input("Enter Celsius: ")) + print(f"{c}°C = {celsius_to_fahrenheit(c):.2f}°F") + elif choice == "2": + f = float(input("Enter Fahrenheit: ")) + print(f"{f}°F = {fahrenheit_to_celsius(f):.2f}°C") + elif choice == "3": + c = float(input("Enter Celsius: ")) + print(f"{c}°C = {celsius_to_kelvin(c):.2f}K") + elif choice == "4": + k = float(input("Enter Kelvin: ")) + print(f"{k}K = {kelvin_to_celsius(k):.2f}°C") + elif choice == "5": + f = float(input("Enter Fahrenheit: ")) + print(f"{f}°F = {fahrenheit_to_kelvin(f):.2f}K") + elif choice == "6": + k = float(input("Enter Kelvin: ")) + print(f"{k}K = {kelvin_to_fahrenheit(k):.2f}°F") + else: + print("Invalid choice ❌") + + +if __name__ == "__main__": + main()