<reponame>QQuinn03/LeetHub
class MovingAverage:

    def __init__(self, size: int):
        self.size=size
        self.arr=[]
        

    def next(self, val: int) -> float:
        self.arr.append(val)
        if len(self.arr)<=self.size:
            return sum(self.arr)/len(self.arr)
        else:
            del self.arr[0]
            return sum(self.arr)/self.size
        


# Your MovingAverage object will be instantiated and called as such:
# obj = MovingAverage(size)
# param_1 = obj.next(val)
class MovingAverage:

    def __init__(self, size: int):
        self.size=size
        self.arr=[]
        

    def next(self, val: int) -> float:
        self.arr.append(val)
        if len(self.arr)<=self.size:
            return sum(self.arr)/len(self.arr)
        else:
            del self.arr[0]
            return sum(self.arr)/self.size
        


# Your MovingAverage object will be instantiated and called as such:
# obj = MovingAverage(size)
# param_1 = obj.next(val)
# Your MovingAverage object will be instantiated and called as such: # obj = MovingAverage(size) # param_1 = obj.next(val)