matrix = [[12.0, 13.0, 1.0], [3.0, 5.0, 2.0]]
Operations on Matrices
As a second exercise, write two functions that return the sum of the elements in the rows/columns of the matrix.
In []:
def sum_columns(matrix):
return a list where element i of the list contains the sum of all elements in column i of the input matrix.
For example, using the matrix [[12, 13, 1], [3, 5, 2]] as input should produce the return value [15, 18, 3].
return []
def sum_rows(matrix):
return a list where element i of the list contains the sum of all elements in row i of the input matrix.
For example, using the matrix [[12, 13, 1], [3, 5, 2]] as input should produce the return value [26, 10].
return []