Python | Numpy numpy.ndarray .__ Pow __ ()



Using the Numpy numpy.ndarray .__ pow __ () method, we get all power elements with the value that is provided as a parameter in numpy.ndarray .__ pow __ () method.

Syntax: ndarray .__ pow __ ($ self, value, mod = None, /)

Return: pow (self, value, mod)

Example # 1:
In this example, we can see that each item receives power with the value specified as a parameter in ndarray .__ pow __ () .

# import an important module into python

import numpy as np

 
# make an array with NumPy

gfg  = np.array ([ 1 , 2 , 3 , 4 , 5 ])

 
# applying the ndarray method .__ pow __ ()

print (gfg .__ pow __ ( 3 ))

Output:

 [1 8 27 64 125] 

Example # 2:

# import an important module into python

import numpy as np

  
# make an array with NumPy

gfg = np.array ([[[ 1 , 2 , 3 , 4 , 5 ],

[ 6 , 5 , 4 , 3 , 2 ]])

 
# applying the ndarray .__ pow __ () method

print < / code> (gfg .__ pow __ ( 2 ))

Exit:

 [[1 4 9 16 25] [36 25 16 9 4]]