All problems
Seasonal Naive Forecast
Problem
The seasonal naive forecast predicts the next value with the observation from one full season ago: forecast = series[-season_length].
Return None if season_length is not positive or exceeds the series length.
Hint
Python's negative indexing does the work once you validate the inputs.
Test cases
case 1
in: [[10,20,30,40,50,60],4]
expected: 30
case 2
in: [[1,2,3,4],1]
expected: 4
case 3
in: [[5,7,9],3]
expected: 5
case 4
in: [[1,2],5]
expected: null
Starter codePython
def seasonal_naive_forecast(series, season_length):
# Your code here
pass4 test cases · run your code against them in the editor