NumPy arrays
A NumPy array is a block of same-typed numbers. Operations apply to every element, in compiled code, without a Python loop.
import numpy as np
a = np.array([1, 2, 3, 4])
print(a * 10) # [10 20 30 40]
print(a.dtype, a.shape) # int64 (4,)
print(a[a > 2]) # [3 4]
m = np.arange(6).reshape(2, 3)
print(m[1, 2]) # row 1, column 2
print(m[:, 0]) # first columna > 2 produces an array of booleans, known as a mask. Using it as an index keeps the matching elements.
Views and copies
A slice is a view, not a copy. Changing it changes the original.
b = a[:2]
b[0] = 99
print(a[0]) # 99
c = a.copy() # independentA mask index, unlike a slice, always returns a new array.
Your task
Write grid(rows, cols) returning an int array of the numbers from 0 in that shape. Write last_column(matrix) returning the final column. Write above_mean(values) returning the elements strictly above the mean. Write zero_negatives(values) returning a copy with negatives set to 0, leaving the input unchanged.
The explanation opens here once every check passes.