So, I have a function:
def function(x,y,z):
result = (x+y)/z
print(result)
I want to assign a result with a specific set of arguments to an object:
data = function(20,10,5)
data
This function with these values should give me 6 as an answer, which it does. However, when I enter "data", to which I assigned this result, nothing happens. I want to store this result to another object so I can call it lates.
I looked up a bit for an answer before posting and also tryed:
class test:
def __init__ (self, x, y, z):
self.x = x
self.y = y
self.z = z
def result(self,x,y,z):
res = (x+y)/z
print(res)
p2 = test(20,10,5)
data = p2.result(20,10,5)
data
I feel like this second try of mine probably don't make any sense. Sorry if it's a dumb question, but I'm a begginer and couldn't find the answer elsewhere.
Thanks in advance!