Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions