Introduction to numpy with example by ShadBox.com

Total Blog Views: 45

Blog Status: publish

Created By: asad_fazlani Created at: 08-06-2021

Tags: python

Numpy

introducrion to numpy || by ProgGeek

Numpy stand for "Numerical Python". Numpy contain powerful n-dimesions array.it is also usefull in linear algebra,random number capabiity etc.
 

installation of numpy : 

to install python numpy
 
step1 : open command prompt(cmd)
 
step2 : write command "pip install numpy" and execute.
 
step3: once you installed open any ide and import numpy "import numpy"
 

Numpy array: 

numpy array is powerful n-dimenssion array which are form in rows and colums.
 

import numpy:

>>> import numpy as np
 

Array (1-d,2-d) : 

>>> print(np.array([1,2,3]))
[1 2 3]
 
>>> print(np.array([[1,2,3],[1,2,3]]))
[[1 2 3]
 [1 2 3]]
 

Ones and Zeros Array using numpy:

>>> ones = np.ones([3,3])
>>> print(ones)
[[1. 1. 1.]
 [1. 1. 1.]
 [1. 1. 1.]]
 
>>> zeros = np.zeros([11,20])
>>> print(zeros)
[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]

 


asad_fazlani

Technical Blogger at shadbox



Comments



  • swazahmad | almost 4 years ago
    Awesome Information Thanks For Sharing
Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads