Can someone help me regarding the subtraction and multiplication of two matrices which I created using arrays (without numpy) and I am doing it using object oriented by making class and functions. I had created 2 matrices and print them by calling the class in objects and now I have to make a function in the same class which subtracts and another function which multiplies these 2 matrices.
Basically, you want to overload the arithmetic operators, for example
def __add__(self, other):
if self.order != other.order:
raise ValueError("Addition requires matrices of the same order")
[self.rows[i][j] + other.rows[i][j] for j in range(self.num_columns)]
for i in range(self.num_rows)
So, you can now do, assuming you have already implemented your basic Matrix class