Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Just need the code for the class SlidingWindowAveragerator and please use the same parameters. It needs to pass all tests. Question 1: Sliding Window Averagerator
Just need the code for the class SlidingWindowAveragerator and please use the same parameters. It needs to pass all tests.
Question 1: Sliding Window Averagerator Complete the code below, defining a sliding window averagerator. The class should have methods: _init__(self, window_size) to initialize, add(self, x), to add a value as well as properties avg and std, as in the previous averagerator classes. 1 ### Question 1: Implement a "slidingWindowAveragerator 2 3 class SlidingwindowAveragerator(object): 4 5 ### YOUR CODE HERE w 6 1 ### 5 points: Tests for SlidingWindowAveragerator 2 3 # First some simple cases. 4 sa = SlidingWindowAveragerator (20) 5 for in range (10): 6 sa. add (10) 7 assert sa. avg == 10 8 assert sa.std == 0 9 10 sa = SlidingWindowAveragerator (10) 11 for _in range(10): 12 sa.add(4) 13 assert sa.avg == 4 14 for in range(10): 15 sa.add(8) 16 assert sa.avg == 8 17 assert sa.std = 0 18 19 N 1 ### 10 points: Now for slightly more complex tests. 2 3 sa = SlidingWindowAveragerator(10) 4 for i in range(10) 5 sa.add(i) 6 assert sa. avg 4.5 7 assert abs(sa.std - 2.87)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started