• Предмет: Информатика
  • Автор: kokacan220
  • Вопрос задан 4 месяца назад

3 Розробіть програму, за допомогою якої у го- ловному вікні розміщуються дві кнопки з на- звами Увести та Ділення. Після натиснення першої кнопки два числа уводяться з клавіа- тури, а після натиснення другої перше число ділиться на друге.​

Ответы

Ответ дал: Аноним
1

Відповідь:

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

Приложения:
Вас заинтересует