← All Python interview questions

Rolling average of daily active users

MediumNumPyGoogleOla

Daily active users are noisy, so the product team reports a smoothed trend line instead.

Write a function moving_average(values, window) that returns a list of rolling averages, each rounded to 2 decimals. Use only full windows — a list of length n with window k returns n - k + 1 values. Return an empty list if the window is larger than the data.

Learn the concept first

Stuck on NumPy? These free Python lessons teach it step by step.

Practising alone only goes so far — our live cohorts pair Python and Pandas depth with dashboards, agentic analytics projects and mock interviews.

Explore the program