You will write three functions that build new events from two old ones: the union, the outcomes in exactly one of the two events, and the outcomes in neither. The checker uses the outcomes of two dice.
The idea. An event is a set of outcomes, and Python sets have the same operations. a | b is the union, a & b the intersection and a - b the difference. Subtract from the whole space to get a complement.
Your tasks.
either(a, b). Return the outcomes that are in a or in b or in both.exactly_one(a, b). Return the outcomes that are in a or in b but not in both.neither(space, a, b). Return the outcomes of space that are in neither event.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…