You will write three small functions: one that finds a probability by counting outcomes, one that finds with the addition theorem, and one that finds the probability of exactly one of two events. The checker uses two dice.
The idea. For equally likely outcomes, is the number of outcomes in divided by the number of outcomes in the space. Use Fraction, so the answers stay exact. The addition theorem says .
Your tasks.
prob(event, space). Return the fraction of outcomes of space for which event(o) is true.p_union(a, b, space). Use the addition theorem with the function from task 1.p_exactly_one(a, b, space). Use .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…