...

/

Challenge: Working with Coroutines

Challenge: Working with Coroutines

Test your understanding of coroutines with these coding questions.

We'll cover the following...

Problem 1

In this problem, you are required to implement a coroutine running_average() that calculates the running average of numbers sent to it.

Requirements

  • The coroutine should:
    1. Start with no numbers.
    2. Accept numbers using .send(value).
    3. After each number is sent, yield the current running average.
  • If .send() is called with None, the coroutine should stop and return the final average.

...