arrays listing continued scales the matrix by the given scalar def scalebyselfscalar )for in rangeself numrows(for in rangeself numcols(selfrc *scalar creates and returns new matrix that is the transpose of this matrix def tranposeself )creates and returns new matrix that results from matrix addition def __add__selfrhsmatrix )assert rhsmatrix numrows(=self numrows(and rhsmatrix numcols(=self numcols()"matrix sizes not compatible for the add operation create the new matrix newmatrix matrixself numrows()self numcols(add the corresponding elements in the two matrices for in rangeself numrows(for in rangeself numcols(newmatrixrc selfrc rhsmatrixrc return newmatrix creates and returns new matrix that results from matrix subtraction def __sub__selfrhsmatrix )creates and returns new matrix resulting from matrix multiplication def __mul__selfrhsmatrix ) matrix object only requires one data field for storing the - array after creating the arrayits elements must be set to zero as specified by the definition of the matrix adt the constructor is provided in lines - the numrows(and numcols(methods are straightforward they need only return the length of the corresponding dimension of the - array the element access methods are also rather simple as they need only call the corresponding method from the array class note that we do not check for valid indices in these methods even though it is precondition as defined by the matrix adt the validation of the precondition is omitted here since we know the corresponding methods of the array class have the same preconditions and they are verified by that class if this were not the casewe would have to validate the indices and raise an exception directly within the methods of the matrix class the scaling matrix operationshown in lines - involves multiplying each element in the matrix by the given scalar value the matrix adt calls for this operation to modify the matrix on which it is applied instead of creating new matrix resulting from the multiplication the matrix add operationon the other handcreates and returns new matrix object that is the result of adding the