You will work out probabilities for a bag of coloured balls, find how many balls to add, and test the theory by drawing many times.
Your tasks.
p_colour, return the probability of drawing colour from bag as a Fraction. The bag is a dictionary such as {"red": 3, "blue": 5}.red_to_add, return the smallest number of red balls to add so that the probability of red is at least target.{"red": 2, "blue": 3, "green": 5}, putting it back each time, and set share to the fraction of draws that were red.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…