Python NumPy library functions are used

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.