UPDATE: I now understand that this was actually just some confusion about scope vs import. I was updating global values and I couldn't find a way of returning more than one value from the other "Sum Function" file. Now, I know that can easily be done using a tuple as pointed out by Alex.
So, this is some code that I wrote. As you can probably see that my math functions don't really take any parameters. And I'm trying to change it as such the Sum, Subtraction and functions like those take two parameters while functions like sin only take one.. Now what i wanted to ask was that how could I achieve giving it parametersn and return the answer instead of updating global values like I've done here. Any and all help will be appreciated
from tkinter import *
import math
root= Tk()
num1=StringVar()
txtDisplay = Entry(root, textvariable = num1, width=17, font='Arial 25',justify="right");
txtDisplay.focus();
txtDisplay.grid(columnspan=5,row=0,ipady=8,padx=18,pady=10)
a=0
common=''
condition=0
oneButton = Button(root, text="1", width='5',command = lambda: clck(1 ))
oneButton.grid(row=6, column=1, ipady=8, ipadx=8)
twoButton = Button(root, text="2", width='5',command = lambda: clck(2))
twoButton.grid(row=6, column=2, ipady=8, ipadx=8)
addButton = Button(root, text="+", width='5',command = lambda: addition() )
addButton.grid(row=7, column=4, ipady=8, ipadx=8, padx=(0, 11))
subButton = Button(root, text="-", width='5',command = lambda: subtraction() )
subButton.grid(row=8, column=4, ipady=8, ipadx=8, padx=(0, 11))
sinButton = Button(root, text="sin", width='5',command = lambda: sin() )
sinButton.grid(row=9, column=4, ipady=8, ipadx=8, padx=(0, 11))
def clck (number):
global common
common+= str(number)
num1.set(common)
def sin():
global common
global a
a = math.sin(int(a))
num1.set(a)
def addition():
global a
global common
try:
a=a+ int(common)
except:
pass
#print(a)
num1.set(a)
common=''
global condition
condition='add'
def subtraction():
global a
global common
a=a- int(common)
#print(a)
num1.set(a)
common=''
root.mainloop()
Also, I know right now that I've only implemented a couple buttons. If there's any way that my code could be improved let me know that as well and if there's anything that you don't get.