Calculating a moving average - using python

You are given a list of numbers J and a single number p. Write a function to return the minimum and maximum averages of the sequences of p numbers in the list J.

For example, given:

J = [4, 4, 4, 9, 10, 11, 12]

p = 3

The sequences will be:






Here the minimum average will be 4 and the maximum average will be 11, which corresponds to the first and last sequences.

Ace your next data science interview

Get better at data science interviews by solving a few questions per week