FunctionRacerProblemsRace

Price and Its Average

MediummatplotlibPython

Draw prices as a line against the day numbers 0, 1, 2, ... with the label "price". On the same chart draw its k-day moving average with the label "average": the mean of each k prices in a row, placed at the day of the last of them, so that line starts at day k - 1. Show the legend and return the figure.

Checked: the lines with their labels and the legend.

Example 1

prices [10,12,11,15,14,18]
k 3
draws
The chart to draw in example 1 of Price and Its Average

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More matplotlib problems