Python | Numpy matrix.put ()

With the Numpy matrix.put () method, we can put a value by passing the index and value into the given matrix.

Syntax: matrix.put (index, value)

Return: Return new matrix

Example # 1:
In this example, we see that we can place a value from a given matrix using the matrix.put () .

# import important module into python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[64, 1; 12, 3]` )

 
# applying the method matrix.put ()

gfg.put (( 0 , 1 ), 45 )

 

print (gfg)

Output:

 [[45 45] [12 3]] 

Example # 2:

# import important module in python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[1, 2, 3 ; 4, 5, 6; 7, 8, -9] ` )

  
# applying the matrix.put () method

gfg.put ( 2 , 43 )

 

print (gfg)

Exit:

 [[1 2 43] [4 5 6] [7 8 -9]]