From dec9bd1ff8ceca30238f127a5b530ef40b83053d Mon Sep 17 00:00:00 2001 From: Kshitij Ambre Date: Sun, 28 May 2023 09:23:49 +0100 Subject: [PATCH 1/5] Temperature_Converter added --- Temperature-Converter/README.md | 20 +++++++ Temperature-Converter/temp-converter.py | 69 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 Temperature-Converter/README.md create mode 100644 Temperature-Converter/temp-converter.py diff --git a/Temperature-Converter/README.md b/Temperature-Converter/README.md new file mode 100644 index 00000000..c7329c38 --- /dev/null +++ b/Temperature-Converter/README.md @@ -0,0 +1,20 @@ +Temperature Converter + +This Python script allows you to convert temperature from Fahrenheit to Celsius. + +Usage +Run the script using a Python interpreter. +You will be prompted to enter a temperature in Fahrenheit. +After entering a valid number, the script will convert it to Celsius and display the result. +The program will continue to prompt for temperature conversions until a valid number is entered. +To exit the program, enter any non-numeric value. +Installation +Clone the repository or download the script file temperature_converter.py to your local machine. + +Ensure you have Python installed (version 3.5 or above). + +Open a terminal or command prompt and navigate to the directory where the script is saved. + +Run the script using the following command: + +python temperature_converter.py \ No newline at end of file diff --git a/Temperature-Converter/temp-converter.py b/Temperature-Converter/temp-converter.py new file mode 100644 index 00000000..d9c5e2b8 --- /dev/null +++ b/Temperature-Converter/temp-converter.py @@ -0,0 +1,69 @@ +import tkinter as tk +from tkinter import messagebox + +def convert_temperature(): + temperature = entry.get() + try: + temperature = float(temperature) + selected_unit = unit_choices.get() + + if selected_unit == "Celsius": + if selected_choice.get() == "Kelvin": + converted_temp = temperature + 273.15 + messagebox.showinfo("Conversion Result", f"{temperature}°C is equivalent to {converted_temp} K") + elif selected_choice.get() == "Fahrenheit": + converted_temp = (temperature * 9/5) + 32 + messagebox.showinfo("Conversion Result", f"{temperature}°C is equivalent to {converted_temp}°F") + + elif selected_unit == "Kelvin": + if selected_choice.get() == "Celsius": + converted_temp = temperature - 273.15 + messagebox.showinfo("Conversion Result", f"{temperature} K is equivalent to {converted_temp}°C") + elif selected_choice.get() == "Fahrenheit": + converted_temp = (temperature - 273.15) * 9/5 + 32 + messagebox.showinfo("Conversion Result", f"{temperature} K is equivalent to {converted_temp}°F") + + elif selected_unit == "Fahrenheit": + if selected_choice.get() == "Celsius": + converted_temp = (temperature - 32) * 5/9 + messagebox.showinfo("Conversion Result", f"{temperature}°F is equivalent to {converted_temp}°C") + elif selected_choice.get() == "Kelvin": + converted_temp = (temperature - 32) * 5/9 + 273.15 + messagebox.showinfo("Conversion Result", f"{temperature}°F is equivalent to {converted_temp} K") + + except ValueError: + messagebox.showerror("Error", "Please enter a valid temperature value.") + +# Create the tkinter window +window = tk.Tk() +window.title("Temperature Converter") +window.geometry("300x200") # Set the initial window size + +# Create the entry field +entry = tk.Entry(window) +entry.pack() + +# Create the dropdown menu for temperature unit choices +unit_choices = tk.StringVar(window) +unit_choices.set("Celsius") # Set the default unit as Celsius +unit_dropdown = tk.OptionMenu(window, unit_choices, "Celsius", "Kelvin", "Fahrenheit") +unit_dropdown.pack() + +# Create the radio buttons for temperature choices +selected_choice = tk.StringVar(window, "Celsius") # Set the default choice as Celsius + +kelvin_radio = tk.Radiobutton(window, text="Kelvin", variable=selected_choice, value="Kelvin") +kelvin_radio.pack() + +celsius_radio = tk.Radiobutton(window, text="Celsius", variable=selected_choice, value="Celsius") +celsius_radio.pack() + +fahrenheit_radio = tk.Radiobutton(window, text="Fahrenheit", variable=selected_choice, value="Fahrenheit") +fahrenheit_radio.pack() + +# Create the conversion button +convert_button = tk.Button(window, text="Convert", command=convert_temperature) +convert_button.pack() + +# Run the tkinter event loop +window.mainloop() From 9a820dc8b2a4b788c58af67e0f6660e1e7ccfb9e Mon Sep 17 00:00:00 2001 From: ambrecodes <113693379+ambrecodes@users.noreply.github.com> Date: Mon, 29 May 2023 08:32:36 +0530 Subject: [PATCH 2/5] Update README.md --- Temperature-Converter/README.md | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Temperature-Converter/README.md b/Temperature-Converter/README.md index c7329c38..fa7a7461 100644 --- a/Temperature-Converter/README.md +++ b/Temperature-Converter/README.md @@ -1,20 +1,30 @@ Temperature Converter +A simple temperature converter application built with Python and tkinter. This application allows you to convert temperature values between Celsius, Fahrenheit, and Kelvin. -This Python script allows you to convert temperature from Fahrenheit to Celsius. - -Usage -Run the script using a Python interpreter. -You will be prompted to enter a temperature in Fahrenheit. -After entering a valid number, the script will convert it to Celsius and display the result. -The program will continue to prompt for temperature conversions until a valid number is entered. -To exit the program, enter any non-numeric value. -Installation +Features +Convert temperature values between Celsius, Fahrenheit, and Kelvin. +User-friendly graphical user interface (GUI) built with tkinter. +Input validation to ensure valid temperature values are entered. +Prerequisites +Python 3.x +Getting Started Clone the repository or download the script file temperature_converter.py to your local machine. -Ensure you have Python installed (version 3.5 or above). - -Open a terminal or command prompt and navigate to the directory where the script is saved. +Install the required dependencies by running the following command: +Copy code +pip install tkinter Run the script using the following command: -python temperature_converter.py \ No newline at end of file +Copy code +python temperature_converter.py +Enter the temperature value in the input field. + +Select the input unit from the dropdown menu. + +Choose the desired output unit using the radio buttons. + +Click the "Convert" button to perform the temperature conversion. + +The converted temperature will be displayed in a pop-up dialog box. + From 94f1a1ed8a677c6a4c0ce134566e47c849a9063b Mon Sep 17 00:00:00 2001 From: ambrecodes <113693379+ambrecodes@users.noreply.github.com> Date: Mon, 29 May 2023 08:33:28 +0530 Subject: [PATCH 3/5] Update README.md --- Temperature-Converter/README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Temperature-Converter/README.md b/Temperature-Converter/README.md index fa7a7461..f8edd459 100644 --- a/Temperature-Converter/README.md +++ b/Temperature-Converter/README.md @@ -4,20 +4,16 @@ A simple temperature converter application built with Python and tkinter. This a Features Convert temperature values between Celsius, Fahrenheit, and Kelvin. User-friendly graphical user interface (GUI) built with tkinter. -Input validation to ensure valid temperature values are entered. -Prerequisites -Python 3.x + Getting Started Clone the repository or download the script file temperature_converter.py to your local machine. Install the required dependencies by running the following command: - -Copy code pip install tkinter -Run the script using the following command: -Copy code +Run the script using the following command: python temperature_converter.py + Enter the temperature value in the input field. Select the input unit from the dropdown menu. From 80ef640f3042a5b3184b9f5807b49e0dc383bd1b Mon Sep 17 00:00:00 2001 From: ambrecodes <113693379+ambrecodes@users.noreply.github.com> Date: Mon, 29 May 2023 08:33:40 +0530 Subject: [PATCH 4/5] Update README.md --- Temperature-Converter/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Temperature-Converter/README.md b/Temperature-Converter/README.md index f8edd459..6c0ca987 100644 --- a/Temperature-Converter/README.md +++ b/Temperature-Converter/README.md @@ -1,4 +1,6 @@ Temperature Converter + + A simple temperature converter application built with Python and tkinter. This application allows you to convert temperature values between Celsius, Fahrenheit, and Kelvin. Features From d89d1383f70b4a50dc9c53caab198320801b2d2d Mon Sep 17 00:00:00 2001 From: ambrecodes <113693379+ambrecodes@users.noreply.github.com> Date: Mon, 29 May 2023 08:34:21 +0530 Subject: [PATCH 5/5] Update README.md --- Temperature-Converter/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Temperature-Converter/README.md b/Temperature-Converter/README.md index 6c0ca987..aa356b2d 100644 --- a/Temperature-Converter/README.md +++ b/Temperature-Converter/README.md @@ -4,10 +4,14 @@ Temperature Converter A simple temperature converter application built with Python and tkinter. This application allows you to convert temperature values between Celsius, Fahrenheit, and Kelvin. Features + + Convert temperature values between Celsius, Fahrenheit, and Kelvin. User-friendly graphical user interface (GUI) built with tkinter. Getting Started + + Clone the repository or download the script file temperature_converter.py to your local machine. Install the required dependencies by running the following command: