You will write a function for the probability of an event, list the prime numbers on a spinner, and find their chance.
The idea. With equally likely outcomes, is the number of favourable outcomes divided by the number of all outcomes. Python's Fraction keeps the answer exact.
Your tasks.
probability, return Fraction(len(favourable), len(outcomes)).primes to the prime numbers on the spinner, in order.p_prime to the probability of a prime, using your function.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…