Create a graphical application that accepts user inputs, performs some operation on them, and then writes the output on the screen.

import tkinter as tk
 
def pound_to_kg():
   pound=float(pound_text.get())
   kg_value=pound*0.454
   kg_value_label['text']=str(kg_value)
 
window=tk.Tk()
label=tk.Label(text="pound to kg converter")
pound_label=tk.Label(text="enter value in pounds")
label.pack() #show label on window
pound_label.pack()   # show label on window
pound_text=tk.Entry() #box for input
pound_text.insert(0,1)
pound=float(pound_text.get()) #change text to float and store the value
 
 
pound_text.pack() #show box on window
kg_label=tk.Label(text='value in kilograms is')
kg_label.pack() # show label on window
convert_button=tk.Button(text='convert',command=pound_to_kg)
kg_value=pound*0.454 # formula for kg
kg_value_label=tk.Label(text=str(kg_value)) #show kg value as text on label
kg_value_label.pack() #show label
convert_button.pack()
 
window.mainloop()
 
Explanation: In this program we are creating a Graphical user interface example. We are creating a pound to KG converter. user enters the pound value in input box and gets the converted Kilogram value below it on a Label. First we are importing tkinter library. this library has functions for creating graphical interfaces, such as labels, textbox, forms, and other types of GUI interfaces.
 
Window object is getting a reference of tkinter window form object. label object is a reference to a label component. text is a attribute of this object. we can set the label text to show. pack() function shows the label component on window form. similarly a entry object is created, where we have to enter pound value. pound variable is having float value from entry box(text box)
 
pack() function then shows entry box on window. again one label object is created to display value in Kilogram(s) on window and text to show is set using text attribute. kg_label is also packed on window. convert_button object references to button object and command property calls pound_to_kg function. Then some conversion logic is applied and new label for dispaly is created. kg_value is converted to string(characters) to show on label as text.
 
window.mainloop() function runs the program and executes it.