Question: Python - troubleshoot makeMatrix() and modify it to meet the conditions below # - accept no parameters # - add a docstring # - create

Python

- troubleshoot makeMatrix() and modify it to meet the conditions below

# - accept no parameters

# - add a docstring

# - create a list of lists such that the values in the 5x5 matrix are:

# 11111

# 22222

# 33333

# 44444

# 55555

# - currently the matrix is created as:

# 12345

# 12345

# 12345

# 12345

# 12345

# - add the values in each row and store in rowSumList

# --- right now the rowSumList is computed incorrectly

# - return 2 values; the matrix & the rowSumList

#==========================================================================

def makeMatrix():

mtx = []

for x in range(5):

mtx.append([])

for y in range(5):

mtx[x].append(y + 1)

rowSumList = [0,0,0,0,0]

print("Current matrix:")

for x in range(5):

for y in range(5):

print(mtx[x][y], end='')

rowSumList[y] += mtx[x][y]

print()

print("rowSumList:",rowSumList)

return mtx, rowSumList

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 Databases Questions!