Your question is Moving Average Sliding Window. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Kronos market-monitoring tools receive a chronological sequence of stock prices. Given the prices and a window size, return the average price for every contiguous window of that size.
Use a rolling sum so that each price enters and leaves the active window once. Return the results from left to right, where the first result corresponds to prices[0:window].
Implement moving_average(prices, window):
prices, a list of integers or floating-point numbers, and window, a positive integer.len(prices) - window + 1.def moving_average(prices, window):