# Seven Detailed Examples Using The Addition Rule

Recall that the addition rule is used to calculate the probability that one event or another event (or both) occur.
Here is the formula:

P(A or B) = P(A) + P(B) - P(A and B)

A detailed explanation of the addition rule is part of the DISCOVERY course content:

Before we begin, let's import our pandas library:

Now we're ready to dive into some examples! All of the examples on this page include a solution with manual calculations. The latter half of the examples also include a possible Python solution.

# Example 1: Milk Tea (Simple)

Kevin went to get milk tea at his go-to spot, TPumps. His drink toppings consists of 50% honey boba, 10% popping boba, and 40% lychee jelly. There's a 12.5% chance that Kevin gets both popping boba and lychee jelly in one sip of his milk tea. What is the probability that when Kevin takes his first sip of his milk tea, he gets either popping boba or lychee jelly?

#### Example 1 Solution:

###### Hand Calculations:

P(popping boba) = 0.1
P(lychee jelly) = 0.4
P(popping boba and lychee jelly) = 0.125.

We can then calculate:
P(popping boba or lychee jelly) = 0.1 + 0.4 - 0.125= 0.375

# Example 2: A Lottery (Simple)

What is the probability you can buy a seat that is either on the bottom level or for a ticket price less than $200? #### Example 4 Solution: ###### Hand Calculations: P(bottom level) = 6150⁄15000 = 0.41 P(price below$200) = (1000 + 100 + 6000)15000 = 0.4733
P(bottom level and price below $200) = P(price below$200 | bottom level) * P(bottom level)
= (1000⁄6150) * 0.41 = 0.0667

We can then calculate:
P(bottom level or price below \$200) = 0.41 + 0.4733 - 0.0667= 0.8166

A detailed explanation of the multiplication rule is part of the DISCOVERY course content:

# Example 5: Jellyfish (with Python)

Karen went hiking up a mountain and stumbled upon a pond of jellyfish. Next to the pond stood a sign detailing the jellyfish in the pond: 5 Fried Egg Jellyfish, 3 Upside-Down Jellyfish, 6 Cannonball Jellyfish, and 3 Helmet Jellyfish as well as a warning not to swim in the pond.
Below is a DataFrame representing all the jellyfish living in the pond:

Tired fom her hike up the mountain, Karen decides to ignore the sign and instead take a relaxing swim in the pond. Of course, she's guaranteed to get stung by a jellyfish. What is the probability that Karen is stung by either a Fried Egg Jellyfish or a Cannonball Jellyfish?

#### Example 5 Solution:

###### Hand Calculations:
Total Jellyfish in the pond: 17
P(Fried Egg) = 5⁄17 = 0.2941
P(Cannonball) = 6⁄17 = 0.3529

Notice that in this question, (NAME) can't be stung by two jellyfish at once, so the two events are mutually exclusive.
In other words, P(Fried Egg and Cannonball) = 0.

We can then calculate:
P(Fried Egg or Cannonball) = 0.2941 + 0.3529 = 0.647

# Example 6: What's for Lunch? (with Python)

A group of 20 friends are trying to decide what to order for lunch. Five of the friends want to eat at Cheesecake Factory, eight of the friends want to eat at Counter, and the remaining seven want to eat at McDonald's. To fairly decide, the friends decide to put 20 slips of paper into a hat, each slip representing one friend's chosen restaurant.
Below is a DataFrame representing all the pieces of paper in the hat:

One slip will be randomly selected as the winning restaurant for lunch.
What is the probability that Cheesecake Factory or Counter is selected?

#### Example 6 Solution:

###### Hand Calculations
P(Cheesecake Factory) = 5⁄20 = 0.25
P(Counter) = 8⁄20 = 0.4
Notice that these are mutually exclusive: two restaurants can't be chosen at the same time. In other words, P(Cheesecake Factory and Counter) = 0.

We can then calculate:
P(Cheesecake Factory or Counter) = 0.25 + 0.4 = 0.65

# Example 7: Is a Hotdog a Sandwich? (with Python)

In a small survey, 32 people responded to the question "Is a hotdog a sandwich?".

• 50% of the respondents were female and the rest were male.
• 11 people responded with 'yes' and 21 responded with 'no'.
• Of the female participants who took the survey, 5 responded with 'yes'.

Below is a DataFrame representing all the responses to the survey:

What is the probability that a randomly selected respondent from the survey is female or said that a hotdog is a sandwich?

#### Example 7 Solution:

###### Hand Calculations:
P(female) = 0.5
P(yes) = 11⁄32 = 0.3438
P(female and yes)
= P(yes | female) * P(female)
= 5⁄16 * 0.5 = 0.1563

We can then calculate:
P(female or yes)= 0.5 + 0.34375 - 0.15625= 0.6875
###### Python Calculations:

A detailed explanation of the multiplication rule is part of the DISCOVERY course content: