其他分享
首页 > 其他分享> > 数组运算

数组运算

作者:互联网

In     ar1=np.array(np.arange(5))
Out  array([0,1,2,3,4])

 

In     np.add(ar1,4)     #每个元素都加4
Out  array([4,5,6,7,8])

 

In     ar2=np.array([2,3,4,5,6])
In     ar1+ar2
Out  array([2,4,6,8,10])

 

In     np.add(ar1,ar2)
Out  array([2,4,6,8,10])

 

In     np.add(ar1,ar2,ar1)    #将ar1和ar2相加后的结果返回给ar1

Out  array([2,4,6,8,10])

 

In     ar1

Out  array([2,4,6,8,10])

 

In     a=array([10,20,30,50,60])
In     b=arange(5)
In     c=a-b
In     c
Out    array([10,19,28,47,56])

 

In     b**2
Out    array([0,1,4,9,16])

 

In     a<40
Out    array([True,True,True,False,False,],dtype=bool)

标签:ar1,ar2,运算,10,数组,np,array,Out
来源: https://www.cnblogs.com/jackie-ding/p/14415655.html