subject

Python how do I fix this error I am getting

code:

from tkinter import *
expression = ""

def press(num):
global expression
expression = expression + str(num)
equation. set(expression)

def equalpress():
try:
global expression
total = str(eval(expression))
equation. set(total)
expression = ""

except:
equation. set(" error ")
expression = ""

def clear():
global expression
expression = ""
equation. set("")

equation. set("")

if __name__ == "__main__":
gui = Tk()

gui. geometry("270x150")

equation = StringVar()

expression_field = Entry(gui, textvariable=equation)

expression_field. grid(columnspan=4, ipadx=70)

buttonl = Button(gui, text=' 1', fg='black', bg='white',command=lambda: press(1), height=l, width=7)
buttonl. grid(row=2, column=0)

button2 = Button(gui, text=' 2', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button2.grid(row=2, column=1)

button3 = Button(gui, text=' 3', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button3.grid(row=2, column=2)

button4 = Button(gui, text=' 4', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button4.grid(row=3, column=0)
button5 = Button(gui, text=' 5', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button5.grid(row=3, column=1)
button6 = Button(gui, text=' 6', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button6.grid(row=3, column=2)
button7 = Button(gui, text=' 7', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button7.grid(row=4, column=0)
button8 = Button(gui, text=' 8', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button8.grid(row=4, column=1)
button9 = Button(gui, text=' 9', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button9.grid(row=4, column=2)
button0 = Button(gui, text=' 0', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
button0.grid(row=5, column=0)

Add = Button(gui, text=' +', fg='black', bg='white',command=lambda: press("+"), height=l, width=7)
Add. grid(row=2, column=3)

Sub = Button(gui, text=' -', fg='black', bg='white',command=lambda: press(2), height=l, width=7)
Sub. grid(row=3, column=3)

Div = Button(gui, text=' /', fg='black', bg='white',command=lambda: press("/"), height=l, width=7)
Div. grid(row=5, column=3)

Mul = Button(gui, text=' *', fg='black', bg='white',command=lambda: press("*"), height=l, width=7)
Mul. grid(row=4, column=3)

Equal = Button(gui, text=' =', fg='black', bg='white',command=equalpress, height=l, width=7)
Equal. grid(row=5, column=2)

Clear = Button(gui, text=' Clear', fg='black', bg='white',command=clear, height=l, width=7)
Clear. grid(row=5, column=1)

Decimal = Button(gui, text=' .', fg='black', bg='white',command=lambda: press("."), height=l, width=7)
buttonl. grid(row=6, column=0)

gui. mainloop()

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 15:30, jasssp
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
image
Computers and Technology, 23.06.2019 21:10, jmolina57
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
image
Computers and Technology, 24.06.2019 10:20, silviamgarcia
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
image
Computers and Technology, 24.06.2019 21:30, Xghoued2056
Aobject is used for displaying the results of a question based on stored data. a. query b. report c. table d. form
Answers: 2
You know the right answer?
Python how do I fix this error I am getting

code:

from tkinter import *
...

Questions in other subjects:

Konu
Mathematics, 27.01.2021 20:30
Konu
Biology, 27.01.2021 20:30