Delivery Delay Risk Practice Problem
This data science coding problem helps you practice Probability Fundamentals, delivery delay risk, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Probability Fundamentals.
- Problem ID: 227
- Problem key: 227-delivery-delay-risk
- URL: https://datacrack.app/solve/227-delivery-delay-risk
- Difficulty: easy
- Topic: Probability Fundamentals
- Module: Probability
Problem Statement
# 🧩 Delivery Delay Risk
---
### 🎯 Goal
Calculate the probability that a package is delayed because of at least one tracked delay cause.
---
### 💻 Task
A delivery company tracks two common causes of package delays:
- weather problems
- warehouse issues
Some packages may be delayed by weather only. Some may be delayed by warehouse issues only. Some may be delayed by both.
Your job is to calculate the probability that a randomly selected package is delayed because of at least one of these causes.
Implement `delivery_delay_probability(weather, warehouse, both)`.
---
### 📥 Input
- `weather`: probability a package is delayed because of weather.
- `warehouse`: probability a package is delayed because of warehouse issues.
- `both`: probability a package is delayed because of both causes.
### 📤 Output
- Return the probability that a package is delayed by at least one of the two causes.
- Round the result to 6 decimals.
---
### 🧩 Starter Code
```python
def delivery_delay_probability(weather, warehouse, both):
pass
```
---
### 💡 Example
```python
delivery_delay_probability(0.12, 0.08, 0.03)
```
The function should return the probability as a decimal rounded to 6 decimals.
---
### ⚠️ Common Mistakes
- Returning a percentage like `17` instead of a probability like `0.17`.
Starter Code
def delivery_delay_probability(weather, warehouse, both):
pass