Python Numpy ndarray.__ipow__()

Numpy ndarray.__ipow__()方法的帮助下,我们将得到所有由numpy.ndarray.__ipow__()方法中作为参数提供的元素。

语法: ndarray.__ipow__($self, value, /)s

返回: self**=value

例子#1 :
在这个例子中,我们可以看到,每个元素都被赋予了在ndarray.__ipow__()方法中作为参数提供的值。

# import the important module in python
import numpy as np
      
# make an array with numpy
gfg = np.array([1, 2, 3, 4, 5])
      
# applying ndarray.__ipow__() method
print(gfg.__ipow__(3))

输出:

[  1   8  27  64 125]

例子#2 :

# import the important module in python
import numpy as np
      
# make an array with numpy
gfg = np.array([[1, 2, 3, 4, 5],
                [6, 5, 4, 3, 2]])
      
# applying ndarray.__ipow__() method
print(gfg.__ipow__(2))

输出:

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程