Beginner
Scale each column with broadcasting
Write scale_columns(m, factors). m is a 2-D array (a table of numbers) and factors is a 1-D array with one number per column. Return a new table where column 0 is multiplied by factors[0], column 1 by factors[1], and so on. Use no loop: broadcasting (Topic 14.3) does it.
Write centre_rows(m). For each row, work out that row's own mean (its average, Topic 14.4) and subtract it from every number in that row. Return the new table, again without a loop. Hint: keepdims=True.
What Check tests
scale_columnsscales every column by its own factor- Neither function changes the array it was given
scale_columnskeeps the shapecentre_rowsmakes each row's mean 0centre_rowsgives the expected values- Neither function uses a loop
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.