from tkinter import Tk, Label, Entry, StringVar, Button, messagebox
#ДИЗАЙН
main = Tk()
main.geometry('400x400+800+30')
n1 = Label(main,
text = 'Калькулятор',
font = ['Arial',28]
)
n1.place(x = 80, y = 20)
a_L = Label(main,
text = 'a = ',
font = ['Arial',20]
).place(x = 20, y = 70)
b_L = Label(main,
text = 'b = ',
font = ['Arial',20]
).place(x = 220, y = 70)
#Поле вводу
eV1, eV2 = StringVar(value = '1'), StringVar(value = '1')
e1 = Entry(textvariable = eV1)
e1.place(x = 60, y = 80)
e2 = Entry(textvariable = eV2)
e2.place(x = 260, y = 80)
#КНОПКИ
def plus():
answer.configure(text = f'Відповідь: {int(e1.get())+int(e2.get())}')
b1 = Button(text='a+b',command=plus).place(x = 20, y = 120)
def minus():
answer.configure(text = f'Відповідь: {int(e1.get())-int(e2.get())}')
b2 = Button(text='a-b',command=minus).place(x = 70, y = 120)
def dobutok():
answer.configure(text = f'Відповідь: {int(e1.get())*int(e2.get())}')
b3 = Button(text='a*b',command=dobutok).place(x = 140, y = 120)
def chastka():
answer.configure(text = f'Відповідь: {int(e1.get())/int(e2.get())}')
b4 = Button(text='a/b',command=chastka).place(x = 200, y = 120)
answer = Label(text='Відповідь',font = ['Arial',20])
answer.place(x = 10, y = 350)
main.mainloop()
Ознайомитися з основними методами для рядків та виконати вправи:
Створити програму, що перетворює всі символи у верхній регістр
Створити програму, що повертає True, якщо рядок є числом
Створити програму, що перетворює початкові символи всіх слів у рядку перекладаються у верхній регістр