Technical

Create a Python class that maintains a rolling average of the last N numbers added to it. The class should have methods to add a new number and retrieve the current rolling average.

Business Intelligence Engineer

Amazon

Did you come across this question in an interview?

Your answer

Try Free AI Interview

Google logo

Google

Product Manager

Prepare for success with realistic, role-specific interview simulations.

Product Strategy
Meta logo

Meta

Product Manager

Prepare for success with realistic, role-specific interview simulations.

Product Sense
Meta logo

Meta

Engineering Manager

Prepare for success with realistic, role-specific interview simulations.

System Design
Amazon logo

Amazon

Data Scientist

Prepare for success with realistic, role-specific interview simulations.

Behavioral
  • Create a Python class that maintains a rolling average of the last N numbers added to it. The class should have methods to add a new number and retrieve the current rolling average.
  • Can you build a Python class that tracks a rolling average of the last N numbers?
  • Write a class that maintains a moving average for a dynamic stream of numbers in Python.
  • How would you implement a rolling average tracker using a Python class?
  • Create a class in Python that calculates a moving average based on the most recent N values.
  • Suppose you need to keep a running average of the last N inputs — how would you design that class?
  • Write a Python class with two methods: one to add a number, and another to return the current average of the last N.
  • How would you design a class that supports calculating a rolling average of a fixed-size window?
  • Build a class in Python that computes the average of the latest N numbers each time a new number is added.
  • Design a class that maintains a sliding window and returns the mean of the most recent values.
  • Write a Python class that implements a rolling average with an internal buffer of size N.

Interview question asked to Business Intelligence Engineers interviewing at Amazon: Create a Python class that maintains a rolling average of the last N numbers added to it. The class should have methods to add a new number and retrieve the current rolling average..