NumPy Tutorial for Beginners

NumPy Tutorial for Beginners

If you want to make a career in big data, you need to learn NumPy. Read on to get started with one of Python's most popular libraries.

I will walk you through the basics of NumPy. If you want to do machine learning then knowledge of NumPy is necessary. It one of the most widely used Python libraries. It is the most useful library if you are dealing with numbers in Python. NumPy guarantees great execution speed compared to standard Python libraries. It comes with a great number of built-in functions.

Advantages of using NumPy with Python:

  • Array-oriented computing.
  • Efficiently implemented multi-dimensional arrays.
  • Designed for scientific computation.

First, let’s talk about its installation. NumPy is not part of the basic Python installation. We need to install it after the installation of Python in our system. We can do it by the pip using command, pip install NumPy, or by installing Conda.

We are done with the installation and now we can jump right into NumPy. First, let’s start with the most important object in NumPy, the ndarray or multi-dimensional array. A multi-dimensional array is an array of arrays. In multi-dimensional arrays, this array, [1,2,3], is a one-dimensional array because it contains only one row. The below is array is a two-dimensional array, as it contains multiple rows as well as multiple columns.

[[1 2 3]

[4 5 6]

[7 8 9]]

Let’s do some coding now. Here I am using Jupyter Notebook to run my code; you can use any IDE available and best suited to you.

We start with import NumPy.

In the following code, I am renaming the package to np for convenience sake.

import numpy as np

Now, in order to create an array in NumPy, we use its array function as shown below:

array = np.array([1,2,3])


Output: [1 2 3]

This an example of a one-dimensional array.

Another way to create an array in NumPy is by using the zeros function.

zeros = np.zeros(3)


Output: [0. 0. 0.]

If you look closely at the output, the generated array contains three zeros, but the type of the value is a float and, by default, NumPy creates the array of float values.


Output: numpy.float64

Going back to the first example inside NumPy’s array function, we pass a list so we can also pass the list variable inside the array function and the output will be the same.

my_list = [1,2,3]

array = np.array(my_list)


Output: [1 2 3]

Now, let’s look into how to create a two-dimensional array using NumPy. Instead of passing the list now we have to pass a list of tuples or list of lists as mentioned below.

two_dim_array = np.array([(1,2,3), (4,5,6), (7,8,9)])



[[1 2 3]

[4 5 6]

[7 8 9]]

Note that the number of columns should be equal, otherwise NumPy will create an array of a list.

arr = np.array([[1,2,3], [4,6], [7,8,9]])


Output: [list([1, 2, 3]) list([4, 6]) list([7, 8, 9])]

Now, to create an array of a range, which is very good for making plots, we use the linspace function.

range_array = np.linspace(0, 10, 4)


Output: [ 0. 3.33333333 6.66666667 10. ]

Here, the first argument is the starting point and next is the endpoint and the last argument defines how many elements you want in your array.

Now, to create random arrays we can use the random function. Here, I’ve created an array of random integers, and, therefore, used randint where first I specified the maximum value and then the size of my array.

random_array = np.random.randint(15, size=10)


Output: [ 7 11 8 2 6 4 9 6 10 9]

Now we know the basics of how to create arrays in NumPy. Now let’s look into some of its basic operations. First, we will start by finding the size and shape of an array. Size will give the number of elements in an array whereas shape will give us the shape of an array.

For a one dimensional array, the shape would be (n, ), where n is the number of elements in your array.

For a two dimensional array, the shape would be (n,m), where n is the number of rows and m is the number of columns in your array


Output: 3


Output: (3,)


Output: 9


Output: (3, 3)

If we want to change the shape of an array we can easily do it with the reshape function. It will look like something like this:

two_dim_array = np.array([(1,2,3,4), (5,6,7,8)])

two_dim_array = two_dim_array.reshape(4,2)



[[1 2]

[3 4]

[5 6]

[7 8]]

We need to make sure that the rows and columns can be interchangeable. For example, here, we can change rows and columns from (2,4) to (4,2) but can not change them to (4,3) because, for that, we’d need 12 elements and we have only 8. Doing so will give an error as shown below.

ValueError: cannot reshape array of size 8 into shape (4,3)

To check the dimensions of our array. we can use the ndim function.


Output: 2

Now, to get values from an array, a process known as slicing can be done in various ways. For example, array[1] will fetch the second element of my array, but if we want a range we can use array[0:1], which will give us the first two elements. For the last value of the array, we can use array[-1], which is similar to the standard method of getting elements from a list in Python.

Now to find the sum all we have to use is the sum(), function but if we want to find the sum of the axis we can pass an argument for the axis.


Output: [ 6 8 10 12]


Output: [10 26]

Now to add two arrays all we have to use if + operator. For example:

print(two_dim_array + two_dim_array)


[[ 2 4 6 8]

[10 12 14 16]]

Similarly, we can use other operands as well, like multiple, subtract, and divide.

We have many other operations present in NumPy like sqrt, which will give us the square root of every element, and std, which is used to find the standard deviation. To explore more about these operations visit the NumPy’s documentation.

And that’s it for the introduction of NumPy.

Learn More

Learn Programming with Python Step by Step

MySQL Databases With Python Tutorial

Creating Web Sites using Python and Flask

Complete Python: Go from zero to hero in Python

An A-Z of useful Python tricks

A Complete Machine Learning Project Walk-Through in Python

Learning Python: From Zero to Hero

MongoDB with Python Crash Course - Tutorial for Beginners

Introduction to PyTorch and Machine Learning

Originally published by Prabhat Kashyap at

Top Python Development Companies | Hire Python Developers

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When you look for the developer in hurry you may forget to take note of review and ratings of the company's aspects, but we at TopDevelopers have done a clear analysis of these top reviewed Python development companies listed here and have picked the best ones for you.

List of Best Python Web Development Companies & Expert Python Programmers.

Python NumPy Tutorial for Beginners

Python NumPy Tutorial for Beginners

NumPy, which stands for Numerical Python, is a library consisting of multidimensional array objects and a collection of routines for processing those arrays. Using NumPy, mathematical and logical operations on arrays can be performed.

NumPy, which stands for Numerical Python, is a library consisting of multidimensional array objects and a collection of routines for processing those arrays. Using NumPy, mathematical and logical operations on arrays can be performed.
NumPy is the core library for scientific and numerical computing in Python. It provides high-performance multidimensional array object and tools for working with arrays. Now, let us get started and understand what NumPy actually is.

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Learn Hands-On Python Programming By Creating Projects, GUIs and Graphics

Python is a dynamic modern object -oriented programming language
It is easy to learn and can be used to do a lot of things both big and small
Python is what is referred to as a high level language
Python is used in the industry for things like embedded software, web development, desktop applications, and even mobile apps!
SQL-Lite allows your applications to become even more powerful by storing, retrieving, and filtering through large data sets easily
If you want to learn to code, Python GUIs are the best way to start!

I designed this programming course to be easily understood by absolute beginners and young people. We start with basic Python programming concepts. Reinforce the same by developing Project and GUIs.

Why Python?

The Python coding language integrates well with other platforms – and runs on virtually all modern devices. If you’re new to coding, you can easily learn the basics in this fast and powerful coding environment. If you have experience with other computer languages, you’ll find Python simple and straightforward. This OSI-approved open-source language allows free use and distribution – even commercial distribution.

When and how do I start a career as a Python programmer?

In an independent third party survey, it has been revealed that the Python programming language is currently the most popular language for data scientists worldwide. This claim is substantiated by the Institute of Electrical and Electronic Engineers, which tracks programming languages by popularity. According to them, Python is the second most popular programming language this year for development on the web after Java.

Python Job Profiles
Software Engineer
Research Analyst
Data Analyst
Data Scientist
Software Developer
Python Salary

The median total pay for Python jobs in California, United States is $74,410, for a professional with one year of experience
Below are graphs depicting average Python salary by city
The first chart depicts average salary for a Python professional with one year of experience and the second chart depicts the average salaries by years of experience
Who Uses Python?

This course gives you a solid set of skills in one of today’s top programming languages. Today’s biggest companies (and smartest startups) use Python, including Google, Facebook, Instagram, Amazon, IBM, and NASA. Python is increasingly being used for scientific computations and data analysis
Take this course today and learn the skills you need to rub shoulders with today’s tech industry giants. Have fun, create and control intriguing and interactive Python GUIs, and enjoy a bright future! Best of Luck
Who is the target audience?

Anyone who wants to learn to code
For Complete Programming Beginners
For People New to Python
This course was designed for students with little to no programming experience
People interested in building Projects
Anyone looking to start with Python GUI development
Basic knowledge
Access to a computer
Download Python (FREE)
Should have an interest in programming
Interest in learning Python programming
Install Python 3.6 on your computer
What will you learn
Build Python Graphical User Interfaces(GUI) with Tkinter
Be able to use the in-built Python modules for their own projects
Use programming fundamentals to build a calculator
Use advanced Python concepts to code
Build Your GUI in Python programming
Use programming fundamentals to build a Project
Signup Login & Registration Programs
Job Interview Preparation Questions
& Much More