How can I pass in arguments (a
, b
, c
) to a function for a quadratic formula without having to redefine them in the function? I know I could use self.a
instead of just a
inside the formula (same thing for b
and c
) but how do I pass in the argument self.a
as a
, self.b
as b
, and self.c
into the function?
class Calc:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def quadraticformula(self):
c = self.c
b = self.b
a = self.a
neg = ((b*-1)-(sqrt((b**2)-4*a*c)))/(2*a)
pos = ((b*-1)+(sqrt((b**2)-(4*a*c))))/(2*a)
return (pos,neg)