Define a function running_average that takes an iterable and return a generator that generates running averages, i.e., t
-
answerhappygod
- Site Admin
- Posts: 899604
- 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!