Chapter 2 · Section 7 practice

Dates, Lags, and Changes over Time

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. Parse date text

Warm-up. Convert Date to datetime and print the month numbers as a list.

Write your answer, then run it.

2. Chronological order

Warm-up. Set Date as the index, sort it, and print Sales values in chronological order.

Write your answer, then run it.

3. Inclusive date range

Warm-up. Print values from November 2 through November 4 inclusive.

Write your answer, then run it.

4. Weekday numbers

Build your skills. Print weekday numbers for Sunday 2026-11-01 and Monday 2026-11-02.

Write your answer, then run it.

5. Aggregate two orders

Build your skills. Aggregate revenue into daily totals and print them as a list.

Write your answer, then run it.

6. Previous observations

Build your skills. Print the previous values generated by shift(1).

Write your answer, then run it.

7. Absolute change

Build your skills. Print changes from the previous observation.

Write your answer, then run it.

8. Percentage change

Challenge. Print fractional changes multiplied by 100.

Write your answer, then run it.

9. A partial-month summary

Challenge. Print the total for the seven observed November days, then their mean rounded to two decimals.

Write your answer, then run it.

10. Avoid a zero denominator

Challenge. Calculate growth only when previous Sales > 0 and print the rounded list.

Write your answer, then run it.

Reference answers are locked until all 10 attempts are submitted.