Exercise 558

give the python numpy code which changes the value 11 to 22 in the matrix: A = = np.array ([[5, 2], [3, 8], [11 , 4]])

Solution

import numpy as np

A = np.array([[5, 2],
[3 , 8],
[11,4]])
A[2][0] = 22
print(A)
# You can also use: A[2,0] = 22

Younes Derfoufi
my-courses.net

Leave a Reply