Python Numpy Tutorial For Beginners Master The Basics Quickly

Logan Jul 13, 2026

Python and its abundant libraries have revolutionized the data science and machine learning landscapes. If you're new to both Python and the numerical library NumPy, this tutorial is designed to help you navigate this powerful toolset with ease. Let's begin our NumPy journey by addressing the basics and gradually delving into more intricate features.

Python Numpy Tutorial
Python Numpy Tutorial

NumPy, which stands for 'Numerical Python', is a library that offers support for large multi-dimensional arrays and matrices, along with a collection of high-performance mathematical functions to operate on these arrays. It is primarily used for numerical computations in Python and is efficient and fast due to its capabilities of performing computations in C behind the scenes.

Python Numpy Tutorial For Beginners 1 - Introduction + Installing numpy
Python Numpy Tutorial For Beginners 1 - Introduction + Installing numpy

First Steps with NumPy

Before we start creating arrays, let's import the NumPy library. You can do this using:

NumPy Cheat Sheet for Data Analysts (Chapter 2/15) | Python for Data Analysts Series
NumPy Cheat Sheet for Data Analysts (Chapter 2/15) | Python for Data Analysts Series

import numpy as np

This command not only imports the library but also creates an alias 'np'. Throughout the tutorial, we'll use this alias to call NumPy functions.

Day 27: NumPy in Python for Beginners 🧮
Day 27: NumPy in Python for Beginners 🧮

Creating Arrays

Now, let's create a simple array. Unlike standard Python lists, NumPy arrays are styled in either one- or higher-dimensional structures. Here's a one-dimensional array:

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

NumPy CheatSheet | Python CheatSheets
NumPy CheatSheet | Python CheatSheets

To print this array, use the 'print()' function:

print(arr)

By default, NumPy's array function attempts to make your input into the most efficient data type. For our case, the array will be of datatype np.int32 or np.int64, which is more efficient than a regular Python list.

Python Tutorial
Python Tutorial

Dimensionality in NumPy

Let's create multi-dimensional arrays:

All Important Python Functions for Beginners (Complete Cheat Sheet)
All Important Python Functions for Beginners (Complete Cheat Sheet)
Python Notes for Beginners (Easy + Quick Guide)
Python Notes for Beginners (Easy + Quick Guide)
Python Projects Ideas For Beginners
Python Projects Ideas For Beginners
🐍 Python Programming | Learn Python, Projects & Coding Tips
🐍 Python Programming | Learn Python, Projects & Coding Tips
Python Numpy Tutorial for Beginners 4 - Creating specific arrays, Reshape and more
Python Numpy Tutorial for Beginners 4 - Creating specific arrays, Reshape and more
30 Python Projects For Beginners and Advanced Learners (2023)
30 Python Projects For Beginners and Advanced Learners (2023)
30-Day Python Learning Plan for Beginners | Complete Python Roadmap to Learn Coding Fast
30-Day Python Learning Plan for Beginners | Complete Python Roadmap to Learn Coding Fast
Python Module - A Step by Step Tutorial for Beginners
Python Module - A Step by Step Tutorial for Beginners
Learn Python in 10 days
Learn Python in 10 days
Master Python List Methods 🐍 | Beginner-Friendly Cheat Sheet
Master Python List Methods 🐍 | Beginner-Friendly Cheat Sheet
Python For Beginners
Python For Beginners
How to Learn Python for Free
How to Learn Python for Free
Python Library numpy | Part 36
Python Library numpy | Part 36
Python Library numpy | Part 31
Python Library numpy | Part 31
Python Program to Plot Sine Wave Using Numpy & Matplotlib
Python Program to Plot Sine Wave Using Numpy & Matplotlib
python programming for beginners
python programming for beginners
9 Python Loop Tricks Every Beginner Should Learn (Cheat Sheet)
9 Python Loop Tricks Every Beginner Should Learn (Cheat Sheet)
👩‍💻 Python for Beginners Tutorial
👩‍💻 Python for Beginners Tutorial
10 Python Mini Projects for Beginners | Easy Coding Ideas for Students & Resume
10 Python Mini Projects for Beginners | Easy Coding Ideas for Students & Resume

arr_2d = np.array([[1, 2, 3], [4, 5, 6]])

If you print this array, you'll see it's a 2x3 (two rows, three columns) matrix. Let's see some of its properties:

print(arr_2d.shape)

This will return '(2, 3)', which is the dimensions of the array. More on this in the sections ahead.

Array Attributes and Methods

NumPy arrays come with several attributes and methods. Let's explore a couple:

Size of Array

Every NumPy array has a size attribute which returns the number of elements present in the array. For example,

print(arr.size)

Reshaping Arrays

One common operation in NumPy is reshaping an array. Here's how you can reshape an array:

arr = arr.reshape(5, 1)

This reshape function returns a new array with the specified shape. In this case, we've transformed our initial one-dimensional array into a 5x1 matrix.

Math Operations

NumPy arrays let you perform mathematical operations on them. Here's how you can add, subtract, multiply, or divide arrays:

arr_add = np.add(arr, arr)

For more convenient operations, you can use '+' '−' '*', '/', etc.

Indexing and Slicing

NumPy arrays can also be indexed and formatted, much like Python lists. Here are some basic indexing and slicing operations:

Indexing

If you want to access an element at a particular position in the array:

element = arr[0]

Slicing

Array slicing helps in obtaining a subset of the array. To slice, use the same syntax as Python lists:

subset = arr[start:end:step]

Let's test with a step value:

subset = arr[::2]

As we wrap up this NumPy tutorial, it's evident that NumPy is integral to Python's capabilities for numerical computations. Remember, practice makes perfect. The more you use NumPy, the more comfortable you'll feel operating with it. Now that you've gained a solid foundation, why not try creating some complex multi-dimensional arrays and perform Math operations on them?