Write the function mult_row_scalar(M, row, scalar) to perform the elementary row operation of multiplying a row by a scalar.
Examples:
>>> A = [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
>>> print_matrix(A)
[[3.00, 0.00, 2.00]
[2.00, 0.00, -2.00]
[0.00, 1.00, 1.00]]
>>> mult_row_scalar(A, 1, -1) # multiply row 1 by -1
>>> print_matrix(A)
[[3.00, 0.00, 2.00]
[-2.00, 0.00, 2.00]
[0.00, 1.00, 1.00]]
>>> mult_row_scalar(A, 1, 0.5) # multiply row 1 by 0.5
>>> print_matrix(A)
[[3.00, 0.00, 2.00]
[-1.00, 0.00, 1.00]
[0.00, 1.00, 1.00]]
Hints:
- This function does not return a value. Instead, it modifies the parameter matrix M directly.
- Your function must verify that the row index src and dest are valid and within the bounds of the matrix. Use the assert statement to check this condition and print an error message if necessary.