Complement Probability Practice Problem
This data science coding problem helps you practice Probability Fundamentals, complement probability, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Probability Fundamentals.
- Problem ID: 221
- Problem key: 221-complement-probability
- URL: https://datacrack.app/solve/221-complement-probability
- Difficulty: easy
- Topic: Probability Fundamentals
- Module: Probability
Problem Statement
# 🧩 Complement Probability
---
### 🎯 Goal
Calculate the probability that an event does **not** happen.
---
### 📖 Introduction
The **complement** of an event means everything in the sample space where the event does not occur.
If the event is $A$, its complement is written as:
$$
A^c
$$
Read this as: "not A".
Because either $A$ happens or $A$ does not happen, the event and its complement do not overlap, and together they fill the whole sample space:
$$
P(A) + P(A^c)=1
$$
So:
$$
P(A^c)=1-P(A)
$$
---
### 📥 Input
- `p_event`: probability that event $A$ happens.
### 📤 Output
- Return the probability that event $A$ does not happen, rounded to 6 decimals.
---
### 💻 Task
Implement `complement_probability(p_event)`.
---
### 🧩 Starter Code
```python
def complement_probability(p_event):
pass
```
---
### 💡 Example
```python
complement_probability(0.3)
```
Expected output:
```python
0.7
```
---
### ⚠️ Common Mistakes
- Returning `p_event` instead of `1 - p_event`.
- Thinking the complement is the opposite label only, instead of everything outside event $A$.
Starter Code
def complement_probability(p_event):
pass