Question: function calledprint_matrixthattakes a list and prints in 2D format. The function prints every row on a separate line separated by a tab character. If the

function calledprint_matrixthattakes a list and prints in 2D format. The function prints every row on a separate line separated by a tab character. If the input is not a list, the function prints an error message. Assume that if the input is a list then it is a valid matrix, i.e. the number of columns in each row is equal. Note that you should not print a tab after the last item in the row.

def print_matrix(matrix):

"""

-------------------------------------------------------

Prints a matrix using the following format:

- each row appears on a separate line

- items are separated by a tab character

Use: print_matrix(matrix1)

-------------------------------------------------------

Parameters:

matrix1 - a 2D matrix (list of lists)

Returns:

no returns

-------------------------------------------------------

"""

Save the function under thefunctions.pyfile. program namedt01.pythat tests the functionprint_matrix.

For this python task there is a functions module and a task module. (simplify code as much as possible). This is a practice problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!