Weighted Average
A course grade counts each assignment by its weight. Return the weighted average: the sum of grades[i] * weights[i] divided by the sum of the weights. Return a float.
Example 1
grades [80,100]
weights [1,3]
returns 95.0
(80 * 1 + 100 * 3) / 4 = 95.0.
Constraints
1 <= len(grades) = len(weights) <= 50- Weights are 0 or more and not all 0
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Weighted Row ScoresEasy
- Whole DollarsEasy
- Z-ScoresEasy
- Zero PositionsEasy
- Best Columns of Each RowMedium
- Cells Above Row AverageMedium
- Count Local PeaksMedium
- Deepest Fall From a HighMedium