Distinguish novice from expert

— Given a and b of shapes (10,) and (10,20) respectively, which of the following statements is a valid broadcasting operation:

a) a[:, np.newaxis] + b
b) a + b[:, np.newaxis]
c) a.reshape((10, 20)) + b
d) np.broadcast(a, b)

— Did they learn what I set out to teach?

What is the motivation behind broadcasting?

a) It copies array data to arrays of appropriate shapes so they may be combined.
b) It makes it easy to combine arrays so users don't have to care about the shapes
c) It allows combining arrays of different shapes in a logical way while saving memory
d) It saves computational time by spreading operations over different CPUs

— One short practical exercise

Produce a 3-dimensional array of values that calculate the radius from the origin of all the points in an (X, Y, Z) grid of shape (100, 100, 100), with X, Y and Z ranging from -10 to 10.

X = …
Y = …
Z = …

R = np.sqrt(X**2 + Y**2 + Z**2)