← NumPy
Lesson 1 of 3
Array basics
Watch, read the card, then practise. Creating arrays · Shape and data type · Indexing and slicing
The video for this lesson is being recorded.
Meanwhile, the notes below and the 60-second cards cover the same ideas.
Practise this topicCreating arrays
A NumPy array is a grid of numbers of one type, built for fast maths.
Remember: import numpy as np, then build arrays with np.something().
Shape and data type
shape tells you the size of each dimension; dtype tells you the type of every value.
Remember: Check .shape whenever something looks wrong.
Indexing and slicing
Pick values with [row, column], and ranges with start:stop.
Remember: Rows first, then columns, separated by a comma.
Try the example in Code Lab
import numpy as np print(np.arange(0, 10, 2).tolist(), np.zeros(3).tolist())