Recent Average
Return the average of the last k values of values, as a float. If k is larger than the number of values, average all of them. Hint: negative slices like values[-k:].
Example 1
values [1,2,3,10]
k 2
returns 6.5
The last two values are 3 and 10, which average 6.5.
Constraints
1 <= len(values) <= 100k >= 1
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Running TotalBeginner
- Same PositionsBeginner
- Shopping TotalBeginner
- Side by Side ColumnsBeginner
- Sign of EachBeginner
- Sorted DistinctBeginner
- Standard DeviationBeginner
- Swap Rows and ColumnsBeginner