Mutually Exclusive Events Practice Problem
This data science coding problem helps you practice Probability Fundamentals, mutually exclusive events, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Probability Fundamentals.
- Problem ID: 225
- Problem key: 225-mutually-exclusive-events
- URL: https://datacrack.app/solve/225-mutually-exclusive-events
- Difficulty: easy
- Topic: Probability Fundamentals
- Module: Probability
Problem Statement
# 🧩 Mutually Exclusive Events
---
### 🎯 Goal
Calculate the probability that either of two non-overlapping events happens.
---
### 📖 Introduction
In the previous problem, you learned the general addition rule:
$$
P(A \cup B)=P(A)+P(B)-P(A \cap B)
$$
Now we look at a special case.
Two events are **mutually exclusive** if they cannot happen at the same time.
That means their intersection is empty:
$$
A \cap B = \varnothing
$$
So:
$$
P(A \cap B)=0
$$
Then the general rule becomes:
$$
P(A \cup B)=P(A)+P(B)
$$
For one die roll:
$$
A=\{1\}
$$
$$
B=\{6\}
$$
You cannot roll a `1` and a `6` on the same single roll, so these events are mutually exclusive.
---
### 📥 Input
- `sample_space`: all possible outcomes.
- `event_a`: outcomes in event $A$.
- `event_b`: outcomes in event $B$.
### 📤 Output
- Return $P(A \cup B)$ rounded to 6 decimals.
---
### 💻 Task
Implement `mutually_exclusive_probability(sample_space, event_a, event_b)`.
Assume the provided events are mutually exclusive.
---
### 🧩 Starter Code
```python
def mutually_exclusive_probability(sample_space, event_a, event_b):
sample_space = set(sample_space)
event_a = set(event_a)
event_b = set(event_b)
pass
```
---
### 💡 Example
```python
mutually_exclusive_probability([1, 2, 3, 4, 5, 6], [1], [6])
```
Expected output:
```python
0.333333
```
---
### ⚠️ Common Mistakes
- Using the simplified rule for events that are not mutually exclusive.
- Thinking mutually exclusive means unlikely. It means the events cannot happen together.Starter Code
def mutually_exclusive_probability(sample_space, event_a, event_b):
sample_space = set(sample_space)
event_a = set(event_a)
event_b = set(event_b)
pass