Temperature Conversion
Here is a simple Python program to convert temperature from Celsius to Fahrenheit:
import tkinter as tk
def convert():
celsius = float(entry.get())
fahrenheit = (celsius * 9/5) + 32
result_label.config(text=f"Temperature in Fahrenheit: {fahrenheit}")
root = tk.Tk()
root.title("Temperature Converter")
entry = tk.Entry(root)
entry.pack()
convert_button = tk.Button(root, text="Convert", command=convert)
convert_button.pack()
result_label = tk.Label(root)
result_label.pack()
root.mainloop()
This HTML code displays a simple Python program using the Tkinter module to convert temperature from Celsius to Fahrenheit. The program takes input from the user in Celsius, converts it to Fahrenheit using the formula (celsius * 9/5) + 32, and then displays the result.
The program consists of an entry widget for the user to input the temperature in Celsius, a button widget to trigger the conversion process, and a label widget to display the converted temperature in Fahrenheit.
To run this program, simply copy and paste the code into a Python IDE or text editor, save it as a .py file, and run the script. The Tkinter interface will open, allowing you to input a temperature in Celsius and convert it to Fahrenheit with the click of a button.
This is a useful and practical example of how Python can be used to perform temperature conversions and create interactive user interfaces using Tkinter.