Introduction to the operation of NumPy
Import NumPy as Npprint "Generate 1*10 Matrix" A=np.arange (1,11) **2b=np.arange (1,11) **3c=a+bprint cprint c.shapeprint " Create a 2*10 Matrix "M=np.array ([Np.arange (Ten), Np.arange (Ten)]) #create a 2*10 matrixprint mprint m.shapeprint" Generate Z Ero Matrix "Z1=np.zeros (10,dtype=np.int8) #create Zero Matrixz2=np.zeros ([3,4]) print z1 print z2print" Generate empty Matrix "E=np.empty ([2,2]) #create empty Matrixprint eprint" Create identity matrix with data type equals int8 "Eye1=np.eye (5 , dtype=np.int8) #create identity matrixprint eye1print eye1[0,0] #get element by Indexprint eye1[3,4]print "calculation be Tween The Matrix "Arr1=np.array ([[1,2,3],[4,5,6]]) #calculation between, Matrixarr2=arr1*arr1print Arr1print Arr2print arr2-arr1print arr2/arr1print arr2%arr1print "calculation between a matrix and a number" print 1/arr1print arr1*0 .3print Arr1+0.08print arr1-0.33
Python NumPy library functions are used