Professional Documents
Culture Documents
operation = "N"
flag = 0
def mathadd(x,y):
sum = float(x) + float(y)
return sum
def subtract(x,y):
sum = float(x) - float(y)
return sum
def multiply(x,y):
sum = float(x) * float(y)
return sum
def divide(x,y):
sum = float(x) / float(y)
return sum
def calculate():
text4.delete('0.0', END)
global stored_value
global operation
if operation == "A":
sum = mathadd(stored_value,entry_left.get())
text4.insert('0.0', sum)
print(sum)
operation = "N"
if operation == "S":
sum = subtract(stored_value,entry_left.get())
text4.insert('0.0', sum)
print(sum)
operation = "N"
if operation == "M":
sum = multiply(stored_value,entry_left.get())
text4.insert('0.0', sum)
print(sum)
operation = "N"
if operation == "D":
sum = divide(stored_value,entry_left.get())
text4.insert('0.0', sum)
print(sum)
operation = "N"
def addBtn():
global operation
global flag
operation = "A"
if flag == 0:
stored_value = entry_left.get()
flag = 1
print("Operation is now A!")
def multBtn():
global operation
global flag
operation = "M"
if flag == 0:
stored_value = entry_left.get()
flag = 1
print("Operation is now W!")
def subBtn():
global operation
global flag
operation = "S"
if flag == 0:
stored_value = entry_left.get()
flag = 1
print("Operation is now S!")
def divBtn():
global operation
global flag
operation = "D"
if flag == 0:
stored_value = entry_left.get()
flag = 1
print("Operation is now D!")
window = Tk()
window.title('Calculator')
window.mainloop()