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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started