Have you tried to add a constant element in a matrix?
So this is the recipe on how we can add a constant to each element of a matrix.
import numpy as np
We have only imported numpy which is needed.
We have created a matrix a matirx on which we will perform operation.
matrixA = np.array([[2, 3, 23],
[5, 6, 25],
[8, 9, 28]])
We have made a lambda function to add 100 in every value of matrix. We have created an object to add 100 in the vector form of matrix.
add_100 = lambda i: i + 100
vectorized_add_100 = np.vectorize(add_100)
So the output comes as
[[102 103 123] [105 106 125] [108 109 128]]