← Questions

Robust Python generator, then a weighted one

0
GoogleCodingLast asked Sep 2025
  1. Write a Python generator that yields the numbers of an input list, with unit tests. Handle edge cases such as None values and an empty list.
  2. Change it to yield numbers from the list at random according to a given probability for each, and test that the distribution is right.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding