I'm learning python and what to know what I'm doing below is correct or is there a better way to write it?
class FUNC:
def __init__(self,a,b):
self.a = a
self.b = b
def Add(self):
x = self.a + self.b
return x
def Sub(self):
y = self.a - self.b
return y
class TASKS:
def tsk1(self):
PrintObj1 = FUNC(10,20)
print(PrintObj1.Add())
def tsk2(self):
PrintObj2 = FUNC(100,50)
print(PrintObj2.Sub())
class RUNTASK:
Obj = TASKS()
Obj.tsk1()
Obj.tsk2()
Obj = TASKSrather thanObj = TASKS()maybe? You should not really use capitals as variables unless they are constants however.RUNTASKlooks like it should be a function, not a class. What would it mean to have aRUNTASKobject?