
From tkinter import* from math import*def Radical_click(): if a>=0: c=str(a) ent.insert(END,c)
else: ent.insert(END,"помилка") if a<=0: c=str(a) ent.insert(END,c) else: ent.insert(END,"помилка")def Modul_click(): if a>=0: c=abs(a) ent.insert(END,c) else: ent.insert(END,"помилка") if a<=0: c=abs(a) ent.insert(END,c) else: ent.insert(END,"помилка")a=""tk=Tk()tk.geometry("260x370+600+300")ent=Entry(justify="right",font=("Consolas",14,"bold"))ent.place(x=20,y=20,width=220,height=30)def BC_click(): ent.delete(0,END)BC=Button(text="C",font="14",command=BC_click)BC.place(x=20,y=70,width=40,height=40)def BEqual_click(): global a,b c=float(ent.get()) ent.delete(0,END) if b=="+": a=a+c if b=="-": a=a-c if b=="*": a=a*c if b=="/": a=a/c ent.insert(END,a)Equal=Button(text="=",font="14",command=BEqual_click)Equal.place(x=200,y=70,width=40,height=40)def B0_click(): ent.insert(END,"0")B0=Button(text="0",font="14",command=B0_click)B0.place(x=20,y=310,width=100,height=40)def B1_click(): ent.insert(END,"1")B1=Button(text="1",font="14",command=B1_click)B1.place(x=20,y=250,width=40,height=40)def B2_click(): ent.insert(END,"2")B2=Button(text="2",font="14",command=B2_click)B2.place(x=80,y=250,width=40,height=40)def B3_click(): ent.insert(END,"3")B3=Button(text="3",font="14",command=B3_click)B3.place(x=140,y=250,width=40,height=40)def B4_click(): ent.insert(END,"4")B4=Button(text="4",font="14",command=B4_click)B4.place(x=20,y=190,width=40,height=40)def B5_click(): ent.insert(END,"5")B5=Button(text="5",font="14",command=B5_click)B5.place(x=80,y=190,width=40,height=40)def B6_click(): ent.insert(END,"6")B6=Button(text="6",font="14",command=B6_click)B6.place(x=140,y=190,width=40,height=40)def B7_click(): ent.insert(END,"7")B7=Button(text="7",font="14",command=B7_click)B7.place(x=20,y=130,width=40,height=40)def B8_click(): ent.insert(END,"8")B8=Button(text="8",font="14",command=B8_click)B8.place(x=80,y=130,width=40,height=40)def B9_click(): ent.insert(END,"9")B9=Button(text="9",font="14",command=B9_click)B9.place(x=140,y=130,width=40,height=40)def BPoint_click(): ent.insert(END,".")Point=Button(text=".",font="14",command=BPoint_click)Point.place(x=140,y=310,width=40,height=40)def BMinus_click(): global a,b a=float(ent.get()) b="-" ent.delete(0,END)Minus=Button(text="-",font="14",command=BMinus_click)Minus.place(x=200,y=310,width=40,height=40)def BPlus_click(): global a,b a=float(ent.get()) b="+" ent.delete(0,END)Plus=Button(text="+",font="14",command=BPlus_click)Plus.place(x=200,y=250,width=40,height=40)def BDivide_click(): global a,b a=float(ent.get()) b="/" ent.delete(0,END)Divide=Button(text="/",font="14",command=BDivide_click)Divide.place(x=200,y=130,width=40,height=40)def BMyltiply_click(): global a,b a=float(ent.get()) b="*" ent.delete(0,END)Myltiply=Button(text="*",font="14",command=BMyltiply_click)Myltiply.place(x=200,y=190,width=40,height=40)Radical=Button(text="√",font="14",command=Radical_click)Radical.place(x=80,y=70,width=40,height=40)Modul=Button(text="|x|",font="14",command=Modul_click)Modul.place(x=140,y=70,width=40,height=40)tk.mainloop()пишет ошибка в if a>=0:сама ошибкаTypeError: '>=' not supported between instances of 'str' and 'int'

Ответы на вопрос

Ответ:
ну вот ,
a=""
а это string
Объяснение:



It looks like you've provided Python code that creates a simple calculator interface using the Tkinter library. This calculator can perform basic arithmetic operations such as addition, subtraction, multiplication, and division, as well as other functions like taking the square root and absolute value of a number.
Here's a brief explanation of the code:
- You import the required modules -
tkinter
andmath
. - You define functions for various button clicks (e.g., numbers, operators, special functions like square root, absolute value, clear, and equal).
- You create a Tkinter window (
tk
) and set its geometry. - You create an Entry widget (
ent
) to display the input and output. - You create buttons for various numbers, arithmetic operators, and special functions, associating each button with its respective click function.
The code appears to have a couple of issues, such as missing indentation for the function definitions, and some parts of the code seem to be cut off (e.g., the last line is cut off).
To make this code work, you should correct the indentation and complete any missing parts. If you have specific questions or need assistance with a particular aspect of the code, please let me know, and I'd be happy to help.


Похожие вопросы
Топ вопросов за вчера в категории Английский язык
Последние заданные вопросы в категории Английский язык
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili