Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is Python 3.7 Given this partial code: def getMatrix(numRows, numColumns): '''returns a matrix with the specified number of rows and columns''' m = []
This is Python 3.7
Given this partial code:
def getMatrix(numRows, numColumns): '''returns a matrix with the specified number of rows and columns''' m = [] # the 2D list (i.e., matrix), initially empty for row in range(numRows): matrix_dimensions_string = str(numRows) + "-by-" + str(numColumns) line = input("Enter a " + matrix_dimensions_string + " matrix row for row " + str(row) + ": ") return m
Write a function called getMatrix(numRows, numColumns) that returns a matrix with numRows rows and numColumns columns. The function reads the values of the matrix from the user on a row by row basis. The values of each row must be entered on one line using a space to separate the values. Use loops in your solution. A sample run of this function when it is called as getMatrix(3, 4) to return a 3 by 4 matrix is as follows.
Enter a 3-by-4 matrix row for row 0: 2.5 3 4 1.5 Enter a 3-by-4 matrix row for row 1: 1.5 4 2 7.5 Enter a 3-by-4 matrix row for row 2: 3.5 1 1 2.5
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