Chapter 2 · Section 8 practice

Rolling and Cumulative Methods

Work from question 1 to 10. Edit your Python box, click Run Code, review the result, then click Submit attempt. Reference answers unlock after all ten attempts are submitted. This records completion, not correctness. Each box runs independently. Progress is saved in this browser.

Submitted: 0 / 10

1. A moving mean

Warm-up. Print the three-observation rolling means as a list.

Write your answer, then run it.

2. Recent total

Warm-up. Print the final three-observation rolling sum.

Write your answer, then run it.

3. Early windows

Warm-up. Print rolling means with window 3 and min_periods=1.

Write your answer, then run it.

4. Cumulative sales

Build your skills. Print cumulative sales as a list.

Write your answer, then run it.

5. Running record

Build your skills. Print the running maximum of these sales.

Write your answer, then run it.

6. Combined growth

Build your skills. Print the combined return of +10% and −10%, rounded to two decimals.

Write your answer, then run it.

7. Rows or calendar days

Build your skills. For November 5, print the three-row mean and three-day mean.

Write your answer, then run it.

8. Plot a moving average

Challenge. Plot the original sales and their three-observation mean with a legend, title, and both axis labels.

Write your answer, then run it.

9. Growth from complete prices

Challenge. Calculate cumulative return from the first price and print rounded values. Use price / first price − 1.

Write your answer, then run it.

10. Choose the right accumulation

Challenge. Print the final three-observation sum, total since the start, and running minimum.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.