I’m quite likely not fully understanding something here, but I recently completed the last project for the Scientific Computing with Python Projects - The Probability Calculator.
One issue I found when completing this project is that the last test (which tests your experiment function) will only pass the test conditions when specific random methods are used in your hat function.
For example if you use the random.choice method on the hat contents to remove the balls, this gets you to the desired probability (~27%) in the number of trials (1000). However if you use a different random method i.e. random.shuffle the contents and then pop items from the contents, the resulting probability will not meet the self.assertAlmostEqual requirement (your result needs to be within 1% of 27.2%). If you instead increase the number of trials (e.g. 10000) then with more sampling you can get the random.shuffle selection method to pass.
I think this particular test might need a more lenient probability requirement or alternatively use a much larger sample size to work for different random methods? Or perhaps I am making some error here?