NumPy mock tests
Test yourself on the whole course, against the clock: questions from every module, then coding problems you solve and run right here. Your score comes at the end, with every answer explained.
Each mock test has 12 questions drawn from the lessons, and 45 minutes on the clock, which keeps running if you reload. Questions are worth a point each. Score 60% or more to pass; your best score is kept.
- 01Mock test 112 questions · 45 minutes · 12 points
- 02Mock test 212 questions · 45 minutes · 12 points
Part A · 12 questions
- What does (np.array([3, 8, 1, 9]) > 5).sum() return?
- Why set a seed, as in np.random.default_rng(42)?
- What does replace=False do in rng.choice(names, size=3, replace=False)?
- What does a[::-1] give for a 1D array a?
- What range of values can rng.integers(1, 7) return?
- For a = np.array([1, 2, 3, 4]), what is a[a > 2]?
- Why is a[(a > 1) & (a < 5)] written with brackets around each condition?
- What does argmax() return?
- For a 2D array of students (rows) by subjects (columns), which gives the average of each subject?
- Why does adding shapes (2, 3) and (2,) fail?
- What shape does np.arange(12).reshape(3, -1) produce?
- Why is the median often better than the mean for response times?
Part A · 12 questions
- np.array([1, 2, 3.5]) has which dtype?
- Which operator combines two masks with "and"?
- Two arrays have shapes (2, 3) and (4, 3). How can they be joined?
- What is the shape of np.zeros((3, 4))?
- Can an array of 10 elements be reshaped to (3, 4)?
- What does np.array([1, 2, 3]) * 3 produce?
- What shape does (3, 1) combined with (1, 5) produce?
- In a 2D array m, what does m[:, 0] select?
- Why are NumPy arrays faster than Python lists for maths?
- What dtype results from np.array([1, 2.5, 3])?
- An array has shape (3, 4). How many elements does it hold?
- Why does np.array([0.1, 0.2]).sum() == 0.3 give False?