- Define A Function Running Average That Takes An Iterable And Return A Generator That Generates Running Averages I E T 1 (64.98 KiB) Viewed 25 times
Define a function running_average that takes an iterable and return a generator that generates running averages, i.e., t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Define a function running_average that takes an iterable and return a generator that generates running averages, i.e., t
Define a function running_average that takes an iterable and return a generator that generates running averages, i.e., the i -th element is the average of the first i items of the iterable. For example: Test Result assert (*running_average(range (0))] [] assert [*running_average (range (10))] == [0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5] Answer: (penalty regime: 10, 20, ... %) 1