FunctionRacerProblemsRace

Recent Average

BeginnerNumPyPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems