#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Python · NumPy Tutorial 2026

NumPy Tutorial for Beginners 2026

A complete NumPy tutorial for beginners in 2026 — arrays, operations, broadcasting, indexing, and practical examples to start data analysis with Python.

Tracks
NumPy · Interactive Tutorial Interactive
Topic
—
NumPy concept
Key Function
—
Main API
Use Case
—
Practical use
Learn → Practise → Apply → Master
Click a topic to see the concept, key function, and practical use.

Home / Tutorials / Python Guides / NumPy Tutorial for Beginners 2026

Python · NumPy Tutorial 2026

NumPy Tutorial for Beginners 2026

ARRAYS OPERATIONS BROADCASTING APPLIED Step 1 Create Arrays np.array, zeros, ones Foundation Step 2 Operations Arithmetic, aggregates Compute Step 3 Broadcasting Shape-aware operations Advanced Applied Data Analysis Real projects Master
NumPy learning path — from creating arrays to applying them in real data analysis.

Quick summary — NumPy tutorial for beginners

NumPy is the foundation of data science in Python. It gives you fast, powerful array operations that power everything from Pandas to machine learning libraries.

In this tutorial you will learn:

  1. Creating arrays — different ways to build NumPy arrays.
  2. Array operations — arithmetic and aggregations.
  3. Indexing and slicing — accessing and modifying data.
  4. Broadcasting — perform operations across different shapes.
  5. Practical examples — real-world data analysis use cases.

SECTION 01Installing NumPy

NumPy is easy to install. If you have Python installed, you can add NumPy with pip or via Anaconda:

# Install NumPy with pip
pip install numpy

# Or install a specific version
pip install numpy==2.0.0

# Verify installation
python -c "import numpy; print(numpy.__version__)"
install-numpy.sh
Key insight: If you use Anaconda, NumPy is already installed — you can start using it immediately.

SECTION 02Creating arrays

NumPy arrays (ndarray) are the core data structure. Here are the most common ways to create them:

Function Description Example
np.array() Create from a list np.array([1, 2, 3])
np.zeros() Array of zeros np.zeros((2, 3))
np.ones() Array of ones np.ones((3, 3))
np.arange() Range of values np.arange(0, 10, 2)
np.linspace() Evenly spaced values np.linspace(0, 1, 5)
np.random.rand() Random numbers np.random.rand(3, 3)
import numpy as np

# From a Python list
a = np.array([1, 2, 3, 4, 5])
print(a)  # [1 2 3 4 5]

# 2D array (matrix)
b = np.array([[1, 2, 3], [4, 5, 6]])
print(b)

# Array shape and dtype
print(a.shape)   # (5,)
print(b.shape)   # (2, 3)
print(a.dtype)   # int64 (or int32)
array-creation.py
Key insight: Always check shape and dtype — these are the source of most NumPy bugs.

SECTION 03Array operations

NumPy arrays support fast element-wise operations — much faster than Python lists. Here are the key operations:

Operation Example Result
Element-wise add a + b New array with sums
Element-wise multiply a * b New array with products
Matrix multiply a @ b Matrix product
Sum a.sum() Total of all elements
Mean a.mean() Average
Standard deviation a.std() Spread measure
import numpy as np

a = np.array([1, 2, 3, 4])
b = np.array([10, 20, 30, 40])

# Element-wise operations
print(a + b)     # [11 22 33 44]
print(a * b)     # [10 40 90 160]
print(a ** 2)    # [1 4 9 16]
print(a / 2)     # [0.5 1.0 1.5 2.0]

# Matrix multiplication (2D)
m1 = np.array([[1, 2], [3, 4]])
m2 = np.array([[5, 6], [7, 8]])
print(m1 @ m2)   # [[19 22] [43 50]]
array-operations.py
Key insight: NumPy operations are vectorised — much faster than writing Python loops for the same work.

SECTION 04Indexing and slicing

NumPy supports familiar Python-like indexing, plus advanced features like boolean and fancy indexing:

Type Example Result
Basic indexing a[0] First element
Slicing a[1:4] Elements 1 to 3
Step slicing a[::2] Every other element
2D indexing m[1, 2] Row 1, column 2
Boolean indexing a[a > 2] Elements greater than 2
Fancy indexing a[[0, 2, 4]] Selected elements
import numpy as np

a = np.array([10, 20, 30, 40, 50])

# Basic indexing
print(a[0])       # 10
print(a[-1])      # 50

# Slicing
print(a[1:4])     # [20 30 40]
print(a[::2])     # [10 30 50]

# 2D indexing
m = np.array([[1, 2, 3], [4, 5, 6]])
print(m[0, 1])    # 2
print(m[:, 1])    # [2 5]  (column 1)
print(m[1, :])    # [4 5 6]  (row 1)
indexing.py
Key insight: Boolean indexing is the foundation for filtering data — you'll use it constantly in data analysis.

SECTION 05Broadcasting

Broadcasting lets NumPy perform operations on arrays of different shapes, as long as they're compatible. It's one of NumPy's most powerful features.

Operation Shapes Result
Scalar + array (3,) + scalar Element-wise addition
1D + 1D (3,) + (3,) Element-wise
2D + 1D (3, 2) + (2,) Broadcast along rows
2D + column (3, 2) + (3, 1) Broadcast along columns
Incompatible (3, 2) + (3,) Error
import numpy as np

# Scalar + array
a = np.array([1, 2, 3])
print(a + 10)     # [11 12 13]

# 2D + 1D (broadcast along rows)
m = np.array([[1, 2, 3], [4, 5, 6]])
row = np.array([10, 20, 30])
print(m + row)
# [[11 22 33]
#  [14 25 36]]

# 2D + column vector
col = np.array([[100], [200]])
print(m + col)
# [[101 102 103]
#  [204 205 206]]
broadcasting.py
Key insight: Broadcasting is the secret behind NumPy's speed and elegance — it avoids writing explicit loops.

SECTION 06Interview Q&A — NumPy

Q1What is NumPy and why is it used?

NumPy is a Python library for numerical computing. It provides fast, multidimensional arrays and vectorised operations that form the foundation for data science libraries like Pandas, SciPy, and scikit-learn.

Q2Why is NumPy faster than Python lists?

NumPy arrays are stored in contiguous memory and operations are implemented in compiled C — this makes NumPy much faster than Python loops over lists.

Q3What is broadcasting?

Broadcasting lets NumPy perform operations on arrays with different shapes, automatically expanding dimensions where compatible.

Q4What's the difference between np.array and np.asarray?

np.array creates a new array (copy by default), while np.asarray returns the input as-is if it's already an array — no copy.

Q5How do I reshape a NumPy array?

Use a.reshape(new_shape) or a.ravel() for flattening. Reshape is fast and returns a new view without copying data.

SECTION 07Test yourself — NumPy quiz

Five questions. No sign-up.

0 / 5

Pick an answer to see why it is right or wrong.

SECTION 08Frequently asked questions

Do I need to know Python before NumPy?

Yes — you should be comfortable with Python basics (variables, lists, loops, functions) before diving into NumPy.

Is NumPy used in machine learning?

Yes — libraries like scikit-learn, TensorFlow, and PyTorch use NumPy arrays or compatible structures underneath.

Can I use NumPy for image processing?

Yes — images can be represented as arrays, making NumPy useful for basic image processing tasks.

What's the difference between NumPy and Pandas?

NumPy is for numerical arrays; Pandas is for tabular data with labels. Pandas is built on top of NumPy.

How long does it take to learn NumPy?

With consistent practice, you can learn NumPy basics in 1–2 weeks. Mastering it takes longer and comes with real projects.

Classroom & online · Noida

Learn NumPy and Python for data science

Our Data Science with Python Course is designed for beginners — learn NumPy, Pandas, and machine learning from scratch.

₹15,500 · full programme ₹24,000
  • Beginner-friendly curriculum
  • Hands-on projects
  • Expert mentorship
  • Weekday & weekend batches