Відповідь:
I made a program that when you click clear it clears and when you click change it divides 1 number by 2:
# Import the Tkinter library
from tkinter import *
# Create the main window
root = Tk()
root.title("Division Calculator")
# Create two variables to store the numbers
num1 = 0
num2 = 0
# Create two entry boxes
num1Entry = Entry(root)
num2Entry = Entry(root)
# Create two buttons
clearButton = Button(root, text="Clear", command=lambda: clear())
divideButton = Button(root, text="Divide", command=lambda: divide())
# Define the clear function
def clear():
num1Entry.delete(0, END)
num2Entry.delete(0, END)
# Define the divide function
def divide():
global num1, num2
num1 = int(num1Entry.get())
num2 = int(num2Entry.get())
result = num1 / num2
print("Result:", result)
# Place the entry boxes and buttons in the window
num1Entry.pack()
num2Entry.pack()
clearButton.pack()
divideButton.pack()
# Run the main loop
root.mainloop()
Пояснення:
It's all written on python
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
I made a program that when you click clear it clears and when you click change it divides 1 number by 2:
# Import the Tkinter library
from tkinter import *
# Create the main window
root = Tk()
root.title("Division Calculator")
# Create two variables to store the numbers
num1 = 0
num2 = 0
# Create two entry boxes
num1Entry = Entry(root)
num2Entry = Entry(root)
# Create two buttons
clearButton = Button(root, text="Clear", command=lambda: clear())
divideButton = Button(root, text="Divide", command=lambda: divide())
# Define the clear function
def clear():
num1Entry.delete(0, END)
num2Entry.delete(0, END)
# Define the divide function
def divide():
global num1, num2
num1 = int(num1Entry.get())
num2 = int(num2Entry.get())
result = num1 / num2
print("Result:", result)
# Place the entry boxes and buttons in the window
num1Entry.pack()
num2Entry.pack()
clearButton.pack()
divideButton.pack()
# Run the main loop
root.mainloop()
Пояснення:
It's all written on python