We need to write a program in Python, using while loop. We need to write a progr
ID: 644317 • Letter: W
Question
We need to write a program in Python, using while loop.
We need to write a program in Python, using while loop. Exercise 1: Update a matrix In this exercise, you will write a function called updateMatrix that takes a matrix as a parameter, updates the numbers in the matrix, and prints the updated matrix. The matrix is actually a list of lists as follows. matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 8]] For each row in the matrix, if the row's index is even, increase all the numbers in that row by 1. If the row's index is odd, increase all the numbers in that row by 2. For example, increase numbers in row 0 by 1, increase numbers in row 1 by 2, increase numbers in row 2 by 1, and so on. Print the matrix after updating all numbers in it. Then write a main function that calls updateMatrix(matrix). you will get the following sample output. 2 3 4 6 7 8 8 9 10Explanation / Answer
def main():
Updatematrix(args)
def updatematrix(args):
for i in range (len(args)):
for j range (len(args[i])):
if args[i][0]%2==0 :
args[i][j]=args[i][j]+1:
for j in range (len(args)):
args[i][j]=args[i][j]+2
print(args[i][j]
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.