Question: ------------------------------ Please Use PYTHON ----------------------------------- Please DONT POST ANYTHING if you can't do it FULLY and if you are not 100% SURE FROM YOUR WORK
------------------------------ Please Use PYTHON -----------------------------------
Please DONT POST ANYTHING if you can't do it FULLY and if you are not 100% SURE FROM YOUR WORKbecause I do not want to post same question again and again for to get full answer !!!
Also, All neccessary codes which are mentioned in the questions are given at the end of the questions !!!!
SHOW YOUR WORKING CODE OUTPUT SO RUN YOUR CODE AND SHARE THE SCHREEN SHOT WITH ME

# Implementation of the Array2D ADT using an array of arrays class Array2D: # Create a 2-D array of size num_rows X num_cols def __init__( self, num_rows, num_cols ): # Create a 1-D array to store an array reference for each row self._the_rows = Array( num_rows ) # Create the 1-D arrays for each rows of the 2-D array for i in range( num_rows ): self._the_rows[ i ] = Array( num_cols ) # Return the number of rows in the 2-D array def num_rows( self ): return len( self._the_rows ) # Return the number of cols in the 2-D array def num_cols( self ): return len( self._the_rows[0] ) # Clear the array by setting every element to the given value def clear( self, value ): for row in range( self.num_rows() ): self._the_rows[ row ].clear( value ) # Get the content of the element at position [i, j] def __getitem__( self, ndx_tuple ): assert len( ndx_tuple ) == 2, "Invalid number of array subscriptts." row = ndx_tuple[ 0 ] col = ndx_tuple[ 1 ] assert row >= 0 and row = 0 and col = 0 and row = 0 and colImplementation of Matrix from array import Array2D class Matrix : def __init__( self, numRows, numCols ): self._theGrid = Array2D( numRows, numCols ) self._theGrid.clear( 0 ) def numRows( self ): return self._theGrid.numRows() def numCols( self ): return self._theGrid.numCols() def __getitem__( self, ndxTuple ): return self._theGrid[ ndxTuple[0], ndxTuple[1] ) def __setitem__( self, ndxTuple, scalar ): self._theGrid[ ndxTuple[0], ndxTuple[1] ] = scalar def scaleBy( self, scalar ): for r in range( self.numRows() ) : for c in range( self.numCols() ) : self[r, c] *= scalar def __add__( self, rhsMatrix ): assert rhsMatrix.numRows() == self.numRows() and \ rhsMatrix.numCols() == self.numCols(), \ "Matrix sizes not compatible for the add operation." newMatrix = Matrix( self.numRows(), self.numCols() ) for r in range( self.numRows() ) : for c in range( self.numCols() ) : newMatrix[r, c] = self[r, c] + rhsMatrix[r, c] return newMatrixDemonstrate that the implementation of the Matrix ADT provided in your textbook works as specified. Your implementation must provide the following: str repr--() sub_() add mul_) sub_() transpose() Demonstrate that the implementation of the Matrix ADT provided in your textbook works as specified. Your implementation must provide the following: str repr--() sub_() add mul_) sub_() transpose()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
