NumPy flashcards
Fast maths on whole grids of numbers in Python: the engine under pandas, images and machine learning.
What is NumPy, in one plain sentence?
NumPy is a free Python library for doing maths on many numbers at once, stored in a grid called an .
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What NumPy is and why4 cards
- The key words4 cards
- Getting started3 cards
Core basics
- Making arrays4 cards
- Indexing and slicing4 cards
- Maths without loops5 cards
- Joining, sorting and counting3 cards
Next steps
- Broadcasting3 cards
- Indexing like a pro3 cards
- Matrices and linear algebra3 cards
- Statistics and float care4 cards
- Saving and dates3 cards
Go deeper
- Memory and layout4 cards
- Dtypes and NumPy 2 rules5 cards
- Advanced operations4 cards
- Speed and the wider world4 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversNumPy 2.5Python 3.12+
Checked against
NumPy at a glance
NumPy is a Python library that does maths on thousands or millions of numbers at once, very fast.
A NumPy array is like an egg tray: every slot is the same size and holds the same kind of thing, so you can work on the whole tray in one go.
Words you will meet
- Array
- A grid of numbers that all have the same kind, stored together
- Element
- One number inside an array
- Dimension
- A direction in the grid: a list has 1, a table has 2
- Shape
- How many elements the array has along each dimension, like (3, 4)
- Axis
- The number of one dimension: axis 0 runs down rows, axis 1 runs across columns
- dtype
- The kind of number each element is, like whole number or decimal
- Vectorised
- One command that works on every element at once, with no loop
The steps
- 1. Start from zero (11 cards): What NumPy is, why it is fast, and the words every later card uses.
- 2. Core basics (16 cards): Create arrays, read their shape, slice them, and do maths and statistics without loops.
- 3. Next steps (16 cards): Broadcasting, views, linear algebra and float care: NumPy used every week in real work.
- 4. Go deeper (17 cards): Memory layout, dtype rules, NumPy 2 changes and performance: what a senior engineer knows.
All 11 cards in Start from zero
- What is NumPy, in one plain sentence?
- NumPy is a free Python library for doing maths on many numbers at once, stored in a grid called an array.
- Why not just use a normal Python list of numbers?
- A list can hold anything, so Python checks each item one by one. A NumPy array holds one kind of number packed tightly, so maths runs in fast compiled code, often 50 to 100 times faster.
- Where do you meet NumPy without seeing it?
- Every pandas column, every photo filter in Python, every weather or finance model, and most machine learning code use NumPy arrays underneath.
- What everyday thing is a NumPy array like?
- An egg tray. Every slot is the same size and holds the same thing, and you can carry or wash the whole tray at once instead of one egg at a time.
- What are an array, an element and a dimension?
- An array is the whole grid. An element is one number in it. A dimension is a direction: a row of numbers has 1 dimension, a table has 2, a colour photo has 3.
- What do shape and axis mean?
- Shape counts elements along each dimension: a table of 3 rows and 4 columns has shape (3, 4). Axis 0 is the row direction (down), axis 1 is the column direction (across).
- What is a dtype?
- The kind of number every element is: whole numbers like
int64, decimals likefloat64, or true/falsebool. One array has one dtype. - What does vectorised mean?
- Writing one command that works on every element at once, like
prices * 1.18, instead of a loop that visits each number. - What do you need before starting NumPy?
- Python basics (lists, loops, functions) and NumPy installed with
pip install numpy. School maths like averages is enough; matrices come later. - What does this first NumPy program do?
- It imports NumPy as
np, makes an array of three prices, and adds 18 percent tax to all of them in one line. - What will you be able to do after this topic?
- Build and slice arrays, do maths and statistics on them, use masks and broadcasting, and avoid the memory and dtype bugs that trip up working engineers.
NumPy cheatsheet
Create
np.array(list, dtype=)From a listnp.zeros(shape) / np.ones(shape)Filled arraynp.arange(start, stop, step)Stepped integersnp.linspace(a, b, n)n points from a to bnp.random.default_rng(seed)Reproducible randoma.reshape(-1, 4)New shape, -1 inferred
Select
a[r, c] / a[:, -1]Cell / last columna[a > 0]Boolean mask, copya[[0, 2, 5]]Fancy index, copya[1:5]Slice, viewa[:, None]Add an axisnp.where(c, x, y)Pick element-wise
Compute
a.sum(axis=0, keepdims=True)Reduce, keep shapenp.nanmean(a)Mean ignoring NaNnp.percentile(a, 90)90th percentilea @ bMatrix productnp.linalg.solve(A, b)Solve Ax = bnp.cumsum / np.diffRunning total / change
Care and speed
np.isclose / np.allcloseFloat comparenp.shares_memory(a, b)View checknp.multiply(a, b, out=buf)No temporarynp.add.at(a, idx, 1)Repeated indicesnp.load(p, mmap_mode="r")Bigger than memorya.astype(np.float32)Change dtype (copy)