LearnPy Hub
← NumPy problems
Hard

Moving Average

Read integers and a window size k. Compute the moving average with np.convolve(a, np.ones(k) / k, mode='valid') and print it rounded to 2 decimals as a list.

Input

Numbers; then k.

Output

A list.

Sample 1

Input
1 2 3 4 5
2
Output
[1.5, 2.5, 3.5, 4.5]

Sample 2

Input
10 20 30
3
Output
[20.0]
solution.py
Output appears here
Moving Average · Python practice problem · LearnPy Hub