Skip to content

NumPy Tutorial

NumPy is the foundation of numerical Python. Almost every data-science and ML library — Pandas, scikit-learn, TensorFlow, PyTorch, OpenCV — is built on top of it. Learn NumPy once and the rest of the Python data stack opens up.

This tutorial is beginner-friendly — every code example has a ▶ Run button so you can execute Python right in your browser, edit the code, and see the output immediately.

Topics

# Chapter
1 Introduction — why NumPy, speed comparison
2 Creating arrays — zeros, ones, arange, linspace, random
3 Array attributes — shape, dtype, ndim, size
4 Indexing & slicing — basic, fancy, boolean
5 Reshaping — reshape, transpose, flatten
6 Math operations & universal functions
7 Broadcasting — math on different shapes
8 Aggregations — sum, mean, std, axis
9 Sorting & searching
10 Linear algebra — dot, matmul, inv, eig
11 Random sampling
12 Stacking & splitting arrays
13 Boolean masks & filtering
14 Real-world examples — feature scaling, k-means, image processing

How this tutorial is organized

Every chapter follows the same beginner-friendly format:

  1. Short intro — what the concept is and why it matters.
  2. Runnable code blocks — click ▶ Run to execute. Edit and re-run freely.
  3. Common pitfalls — what beginners get wrong.
  4. Cheatsheet — quick reference at the end.
  5. Next link — pointer to the next chapter.

Prerequisites

  • Python basics — lists, loops, functions.
  • No math background needed (we explain everything).

What you'll be able to do after this

  • Manipulate any numerical array efficiently in Python.
  • Read and write code from any data science / ML library.
  • Apply broadcasting tricks to avoid loops.
  • Compute statistics, solve linear systems, generate random samples.
  • Build the foundational skill behind Pandas, scikit-learn, and PyTorch.

Ready? → Start with Introduction