BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/NumPy Arrays3/3
Exercise·7 min·10 XP

Row Sums

Context. A 2D table of weekly sales — each row is a product, each column a day of the week. You want the total per product.

Your task. Write row_sums(matrix) that takes a 2D list (list of lists) and returns a NumPy array with one entry per row — the sum of that row.

Example. [[1,2,3],[4,5,6]] → array([6, 15]).

Notes. Use .sum() with the right axis argument. Rows with negative values still sum normally (no special-casing). A single-row input still returns a 1-element array.

Previous
Celsius to Fahrenheit
Next
Pick Specific Columns