можно зделать 2 калькулятора они будут разные за видом
-------------------------------------------≪1 Вариант≫------------------------------------------
from tkinter import *
root = Tk()
root.title('Розв’язувач')
root.geometry('250x200')
lab = Label(root, text='Введіть приклад:', font='Arial 18')
lab.place(x=20, y=10)
s = ''
entry1 = Entry(root, text=s, width=16, font='Arial 18')
entry1.place(x=20, y=50)
entry2 = Entry(root, text=s, width=16, font='Arial 18')
entry2.place(x=20, y=140)
def b1_click():
vidp = eval(entry1.get())
entry2.delete(0, END)
entry2.insert(0, vidp)
b1 = Button(root, text='Розв’язати', command=b1_click)
b1.place(x=40, y=90)
root.mainloop()
-------------------------------------------≪2 Вариант≫------------------------------------------
root.title("Калькулятор")
root.geometry("650x50")
lab1 = Label(root, text="#1", font="Arial 18")
lab1.place(x=10, y=10)
lab2 = Label(root, text="#2", font="Arial 18")
lab2.place(x=250, y=10)
lab3 = Label(root, text="=", font="Arial 18")
lab3.place(x=400, y=10)
entry1 = Entry(root, width=6, font="Arial 18")
entry1.place(x=55, y=10)
entry2 = Entry(root, width=6, font="Arial 18")
entry2.place(x=295, y=10)
entry3 = Entry(root, width=6, font="Arial 18")
entry3.place(x=445, y=10)
b1 = Button(root, text="+", command=lambda: b_click("+"))
b1.place(x=150, y=10)
b2 = Button(root, text="-", command=lambda: b_click("-"))
b2.place(x=195, y=10)
b3 = Button(root, text="*", command=lambda: b_click("*"))
b3.place(x=240, y=10)
b4 = Button(root, text="/", command=lambda: b_click("/"))
b4.place(x=285, y=10)
def b_click(operation):
s = entry1.get() + operation + entry2.get()
result = eval(s)
entry3.delete(0, END)
entry3.insert(0, result)
def b2_click():
s = entry1.get() + "-" + entry2.get()
def b3_click():
s = entry1.get() + "*" + entry2.get()
def b4_click():
s = entry1.get() + "/" + entry2.get()
Ответ:
самое простое
Объяснение:
a=int(input('Введите число 1: '))
b=int(input('Введите число 2: '))
print('a+b= ',a+b)
print('a-b= ',a-b)
print('a*b= ',a*b)
print('a/b= ',a/b)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
можно зделать 2 калькулятора они будут разные за видом
-------------------------------------------≪1 Вариант≫------------------------------------------
from tkinter import *
root = Tk()
root.title('Розв’язувач')
root.geometry('250x200')
lab = Label(root, text='Введіть приклад:', font='Arial 18')
lab.place(x=20, y=10)
s = ''
entry1 = Entry(root, text=s, width=16, font='Arial 18')
entry1.place(x=20, y=50)
entry2 = Entry(root, text=s, width=16, font='Arial 18')
entry2.place(x=20, y=140)
def b1_click():
vidp = eval(entry1.get())
entry2.delete(0, END)
entry2.insert(0, vidp)
b1 = Button(root, text='Розв’язати', command=b1_click)
b1.place(x=40, y=90)
root.mainloop()
-------------------------------------------≪2 Вариант≫------------------------------------------
from tkinter import *
root = Tk()
root.title("Калькулятор")
root.geometry("650x50")
lab1 = Label(root, text="#1", font="Arial 18")
lab1.place(x=10, y=10)
lab2 = Label(root, text="#2", font="Arial 18")
lab2.place(x=250, y=10)
lab3 = Label(root, text="=", font="Arial 18")
lab3.place(x=400, y=10)
entry1 = Entry(root, width=6, font="Arial 18")
entry1.place(x=55, y=10)
entry2 = Entry(root, width=6, font="Arial 18")
entry2.place(x=295, y=10)
entry3 = Entry(root, width=6, font="Arial 18")
entry3.place(x=445, y=10)
b1 = Button(root, text="+", command=lambda: b_click("+"))
b1.place(x=150, y=10)
b2 = Button(root, text="-", command=lambda: b_click("-"))
b2.place(x=195, y=10)
b3 = Button(root, text="*", command=lambda: b_click("*"))
b3.place(x=240, y=10)
b4 = Button(root, text="/", command=lambda: b_click("/"))
b4.place(x=285, y=10)
def b_click(operation):
s = entry1.get() + operation + entry2.get()
result = eval(s)
entry3.delete(0, END)
entry3.insert(0, result)
def b2_click():
s = entry1.get() + "-" + entry2.get()
result = eval(s)
entry3.delete(0, END)
entry3.insert(0, result)
def b3_click():
s = entry1.get() + "*" + entry2.get()
result = eval(s)
entry3.delete(0, END)
entry3.insert(0, result)
def b4_click():
s = entry1.get() + "/" + entry2.get()
result = eval(s)
entry3.delete(0, END)
entry3.insert(0, result)
root.mainloop()
Ответ:
самое простое
Объяснение:
a=int(input('Введите число 1: '))
b=int(input('Введите число 2: '))
print('a+b= ',a+b)
print('a-b= ',a-b)
print('a*b= ',a*b)
print('a/b= ',a/b)