Tutorial Playlist

Python Tutorial for Beginners


The Best Tips for Learning Python

Lesson - 1

How to Install Python on Windows?

Lesson - 2

Top 10 Python IDEs in 2020: Choosing The Best One

Lesson - 3

A Beginner’s Guide To Python Variables

Lesson - 4

Understanding Python If-Else Statement

Lesson - 5

Python Numbers: Integers, Floats, Complex Numbers

Lesson - 6

Python Strings | Simplilearn Python Tutorial

Lesson - 7

The Basics of Python Loops

Lesson - 8

Python For Loops Explained With Examples

Lesson - 9

Introduction to Python While Loop

Lesson - 10

Everything You Need to Know About Python Arrays

Lesson - 11

All You Need To Know About Python List

Lesson - 12

How to Easily Implement Python Sets and Dictionaries

Lesson - 13

A Handy Guide to Python Tuples

Lesson - 14

Everything You Need to Know About Python Slicing

Lesson - 15

Python Regular Expression (RegEX)

Lesson - 16

Learn A to Z About Python Functions

Lesson - 17

Objects and Classes in Python: Create, Modify and Delete

Lesson - 18

Python OOPs Concept: Here's What You Need to Know

Lesson - 19

An Introduction to Python Threading

Lesson - 20

Getting Started With Jupyter Network

Lesson - 21

PyCharm Tutorial: Getting Started with PyCharm

Lesson - 22

The Best NumPy Tutorial for Beginners

Lesson - 23

The Best Python Pandas Tutorial

Lesson - 24

An Introduction to Matplotlib for Beginners

Lesson - 25

The Best Guide to Time Series Analysis In Python

Lesson - 26

An Introduction to Scikit-Learn: Machine Learning in Python

Lesson - 27

A Beginner's Guide To Web Scraping With Python

Lesson - 28

Python Django Tutorial: The Best Guide on Django Framework

Lesson - 29

Top 10 Reason Why You Should Learn Python

Lesson - 30

10 Cool Python Project Ideas For Beginners in 2021

Lesson - 31

The Best Ideas for Python Automation Projects

Lesson - 32

12 Tips On How To Become a Python Developer

Lesson - 33

The Best Guide for RPA Using Python

Lesson - 34

Comprehending Web Development With PHP vs. Python

Lesson - 35

The Best Tips for Learning Python - REMOVE

Lesson - 36

The Best Way to Learn About Box and Whisker Plot

Lesson - 37

An Interesting Guide to Visualizing Data Using Python Seaborn

Lesson - 38

The Complete Guide to Data Visualization in Python

Lesson - 39

Everything You Need to Know About Game Designing With Pygame in Python

Lesson - 40

The Complete Simplified Guide to Python Bokeh

Lesson - 41

Top 50 Python Interview Questions and Answers in 2020

Lesson - 42
The Best NumPy Tutorial for Beginners

Although it may sound like the name a child would give to a beloved toy stuffed animal, NumPy refers to Numerical Python. It is an open-source library in Python that aids in mathematical and numerical calculations and computations; and, scientific, engineering, and data science programming. NumPy is an essential library used to perform mathematical and statistical operations. It is especially suited for multi-dimensional arrays and matrix multiplications. This NumPy tutorial focuses on the essential things you need to know to master NumPy.

Learn data operations in Python, strings, conditional statements, and more with the Python Training course. Enroll now!

Getting Started With NumPy

In this Numpy tutorial, we will be using Jupyter Notebook, which is an open-source web application that comes with built-in packages and enables you to run code in real-time.

Let’s get started by importing our NumPy module and writing basic code.

NumPy is usually imported under the np alias.


Fig: Basic NumPy example

You can also make more than a one-dimensional array.

Fig: 2-D NumPy array

Python Training Course

Learn Data Operations in PythonExplore Course
Python Training Course

NumPy Arrays

The array object in NumPy is called ndarray, which means an N-dimensional array. 

To create ndarray in NumPy, we use the array() function.


Fig: NumPy array

NumPy Array functions

  • ndim

The ndim() attribute can be used to find the dimensions of the array.


Fig: ndim function

  • itemsize()

The itemsize() is used to calculate the byte size of each element.


Fig: itemsize()

Each item occupies four bytes in the above array.

  • dtype

The dtype attribute is used to understand the data type of the given element.   


Fig: dtype

  • shape

This array attribute returns a tuple consisting of array dimensions.


Fig: shape

This means the array has two dimensions, and each dimension contains two elements.

  • reshape()

The reshape() function is used to reshape the array. 


Fig: reshape()

Now the array has three dimensions, with two elements in each dimension.

  • Slicing

Slicing is used to extract a range of elements from the array.


Fig: Slicing

Zero represents the index of the array, and one indicates the element of the mentioned array.

Free Course: Introduction to Numpy

Master the Fundamentals of NumpyEnroll Now
Free Course: Introduction to Numpy

  • random.rand()

The random module’s rand() method returns a random float between zero and one.



Fig: random()

We have generated a three-dimensional array with two elements in each dimension. 

  • random.randint()

The randint() method takes a size parameter where you can specify the shape of the array.



Fig: random.randint()

The code above will generate a 2D array with three rows, and each row will contain four random integers between zero and 10.

  • mean()

The mean() function is used to compute the arithmetic mean of the given data along the specified axis.



Fig: mean()

  • median()

The median() function is used to compute the arithmetic median of the given data along the specified axis.



Fig: median()

  • std()

The std() function is used to compute the standard deviation along the specified axis.


Fig: std()

  • append()

The append() function is used to add new values to an existing array.



Fig: append()

  • insert()

The insert() function inserts the value in the input array along the mentioned axis.

Syntax: numpy.insert(arr, obj, values, axis)



Fig: insert()

  • concatenate()

The concatenate() function is used for joining two or more arrays of the same shape along the specified axis.



Fig: concatenate()

Full Stack Web Developer Course

To become an expert in MEAN StackView Course
Full Stack Web Developer Course

NumPy Mathematical Operation

In NumPy, basic mathematical functions operate elementwise on an array. Let’s look at some examples to understand this more clearly.


Fig: Mathematical operations


Fig: Output

NumPy Broadcasting

Broadcasting is NumPy’s ability to perform mathematical operations on arrays with different shapes. 

The following example demonstrates how to multiply two arrays:



In the preceding example, the array was the same shape, and therefore multiplication was simple. However, if we consider arrays of different sizes, we will receive an error message.



NumPy can perform such operations using the concept of broadcasting.

In order to broadcast two arrays together, they must meet the following criteria:

  • If the arrays do not have the same rank, prepend the shape of the array that is ranked lower with ones until both shapes have the same length.
  • The size of each output dimension is the maximum of the input sizes in the dimension.
  • In any dimension where one array had size one, and the other array had a size greater than one, the first array behaves as if it were copied along that dimension.



Fig: NumPy broadcasting


In this NumPy tutorial article, we discussed the basic concepts of NumPy. We looked at how to create a NumPy array, and its different functions. We went through several mathematical operations on NumPy using broadcasting.

If you have any questions, please share them in the comments section, and we'll have our experts answer them for you.

Want to Learn More Web Development?

Web developers with the latest skills in modern tools such as NumPy are in high demand. If you are looking to upskill and take your career to the next level, check out our Full Stack Web Developer - MEAN Stack Master’s program today. You can learn from anywhere and at your own pace with our award-winning, online applied learning model. What are you waiting for?

About the Author

Aryan GuptaAryan Gupta

Aryan is a tech enthusiast who likes to stay updated about trending technologies of today. He is passionate about all things technology, a keen researcher, and writes to inspire. Aside from technology, he is an active football player and a keen enthusiast of the game.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.