I'm try to learning class properties in Python. I'm trying to solve a 2X2 equation. After getting 6 values from the user, I try to make a transaction in the class but it gives an error. Can you help me?
import numpy as np
class HomogenEquation():
def __init__(self,number):
self.number = number
self.value=0
def isSolvable(self,a,d,b,c):
return (a*d)-(b*c)==0
def getXY(self,a,b,c,d,e,f):
x = np.array([[a, b],[c,d]])
y = np.array([e, f])
print(np.linalg.solve(x,y))
a=int(input("a: "))
a_value= HomogenEquation(a)
b=int(input("b: "))
b_value= HomogenEquation(b)
e=int(input("e: "))
e_value= HomogenEquation(e)
c=int(input("c: "))
c_value= HomogenEquation(c)
d=int(input("d: "))
d_value= HomogenEquation(d)
f=int(input("f: "))
f_value= HomogenEquation(f)
if a.isSolvable(a,d,b,c):
getXY(a,b,c,d,e,f)
else:
print("The equation has no solution.")
ais anint,a_valueis the object that has as the method isSolvable. You're calling the wrong object.