There are some nice exercises here, good work.
For question 48 it might be simpler to just write
np.sort(a)[-5:]
instead of using argsort() and then using fancy indexing. Better yet, use np.partition(a, kth=-5)[-5:]
which scales linearly with the size of the array.Also, the one-hot encoding puzzle (51) would be more efficiently solved using
(arr[:, None] == np.unique(arr)).view(np.int8)
In general, `for` loops over NumPy arrays should be avoided where at all possible.