NumPy7 lessons and their Study toolkit.
Watch each lesson, answer its quiz, then do its practice. After the last lesson: the module quiz, the project, and the interview questions.
The lessonsin the order to take them.
- 1.1Why NumPySay what an array holds that a list does not, and why that makes it faster and smaller. Open
- 1.2Shape, dtype and ReshapingRead any array's shape and dtype, and reshape without copying. Open
- 1.3Indexing, Slicing and MasksSelect exactly the elements you want, including by condition. Open
- 1.4Vectorised Operations and BroadcastingCompute on whole arrays at once, and predict when shapes combine. Open
- 1.5Aggregations Along AxesSum, average and find extremes over rows or columns. Open
- 1.6Linear Algebra in NumPyWrite the maths of the ML videos directly as code. Open
- 1.7Random Numbers and ReproducibilityGenerate random data you can reproduce. Open
Glossaryevery term the module introduces.
Each with the lesson that introduces it.
- Array
- Values in a typed buffer, interpreted through a shape 1.1
- Buffer
- Contiguous storage for the array's elements 1.1
- Object dtype
- References to Python objects instead of fixed-width numeric values 1.1
- Shape
- Element count on each axis, as a tuple 1.2
- Dimension /
ndim - An axis / the number of axes 1.2
dtype- The type and width used for array elements 1.2
- Reshape
- Interpret the same number of elements with a new shape; a copy is possible for non-contiguous inputs 1.2
- View
- An array sharing data with another array 1.3
- Copy
- An array with independent data 1.3
- Slice
- Position range with excluded stop; basic slicing generally returns a view 1.3
- Boolean mask
- Boolean array selecting elements where it is true 1.3
- Fancy indexing
- Selection by integer positions; returns a copy 1.3
- Vectorisation
- Applying an operation to an entire array instead of a Python loop over its elements 1.4
- Universal function
- NumPy function applying an operation elementwise 1.4
- Broadcasting
- Matching dimensions from the right, repeating a size-one dimension conceptually 1.4
- Axis
- Dimension named by an operation; reduction removes that dimension 1.5
- Reduction
- Combining values along an axis, such as
sumormean1.5 keepdims- Retain a reduced axis with size one 1.5
argmax- Position of the maximum, not the maximum value 1.5
- Transpose
- Exchange axes of a two-dimensional array 1.6
- Matrix product
- Row-column combination written
@1.6 - Linear system
- Equations represented as
A @ w = b1.6 - Generator
- Object with its own random state and sampling methods 1.7
- Seed
- Starting value used to reproduce a generator's sequence 1.7
- Permutation
- Reordering of positions without duplication 1.7
Module quiz15 questions across it all.
Take it after the last lesson. Your first pick on each question is the one that counts.
Project: The chain's year, in NumPybuild it without a template.
Stated as a problem, with no step-by-step instructions. Working out the steps is the point.
The task
Write one Colab notebook that loads sales.csv and produces a summary of the
chain's year, using NumPy only — no loops over the data, except where you are
explicitly comparing a loop against an array.
It must report:
- the grid's
shape,dtypeandnbytes, and the narrowest dtype that holds theunitscolumn without wrapping; - the chain's total for the year, and each shop's total;
- how many days each shop beat its own target;
- which shop led the chain on each day, and how many days each shop led;
- each shop's revenue standardised against its own mean and spread, and the single best day in the chain on that standardised scale — with the date and the shop;
- the weights that make footfall, promotion and temperature predict revenue, solved from the normal equations;
- a ten row random sample of shop-days that anyone re-running your notebook gets identically.
Notebooksthat check your answers.
Open them in Google Colab. Each answer is checked as you go: correct, wrong with the expected value, or not answered yet.
- Arrays and shapeLessons 1.1 and 1.2 Courses plan
- Selection and broadcastingLessons 1.3 and 1.4 Courses plan
- Axes and linear algebraLessons 1.5 and 1.6 Courses plan
- Random numbers and reproducibilityLessons 1.7 Courses plan
- The chain's yearThe module project, with checks Courses plan
Common mistakesacross the whole module.
What you see when it goes wrong, why it happens, and the fix.
Referencefor revising and for interviews.
The cheat sheet is one page of the module’s terms, rules and gotchas. The interview questions come with model answers.