#------------------------------------------------------------------------------ # Matrix.py #------------------------------------------------------------------------------ """ This module provides functions for performing some standard matrix operations. Matrices are represented as nested lists, i.e. lists of lists of numbers (float or int.) Functions that take two matrix arguments will raise a ValueError() if the matrices are not compatible, i.e. the same number of rows and columns. """ #------------------------------------------------------------------------------ # import statements #------------------------------------------------------------------------------ import random #------------------------------------------------------------------------------ # function definitions #------------------------------------------------------------------------------ # compatible() ---------------------------------------------------------------- def compatible(A, B): """ Returns True if A and B have the same number of rows and columns, and False otherwise. """ result = (len(A)==len(B)) # True or False i = 0 while result and i