Seven Examples of finding Q1 and Q3


When calculating Q1 and Q3, there are two steps:

  1. Find the true location using the following formula:
  • (# of data points - 1) * (percentile of interest)
  1. Calculate Q1 and Q3 using the following formula:
  • low + ((high - low) * fraction%)

A detailed explanation of quartiles and box plots is part of the DISCOVERY course content:


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

import pandas as pd
Importing Pandas Library

Now we're ready to look at some examples! All of the examples on this page include a solution with manual calculations. The last two examples also include a possible Python solution.

Example 1: Ants

In a small myrmecology lecture, students learned that ants can carry 50x to 100x their body weight. The next day in their lab section, they tested this out with 11 carpenter ants which weigh around 136mg on average. After performing a scientific procedure and recording their data (measured in mg), they came up with the following list of data:
6559, 6632, 6855, 6912, 7002, 7142, 7381, 7592, 7620, 7707, 8309
One of the requirements for the lab report is to calculate the quartiles, but you were only assigned the calculation of Q3. What is the Q3 of this list of data?

Example 1 Solution:

First, let's calculate the true location. There are 11 data points and, since we are interested in finding Q3, the percentile of interest is 0.75.
We can then calculate:
true location = (11 - 1) * 0.75 = 7.5
Using the true location, we want to find the 7.5th number in our list of data, which is between 7592 (low) and 7620 (high). The fraction percent is 0.5, which is the decimal component of the true location.
We can then calculate:
Q3 = 7592 + ((7620 - 7592) * 0.5) = 7606


Example 2: Board Breaking

At the Koolest Karate Dojo, 10 black belt students were tested to see how many wood boards they could break in 30 seconds. The sensei of the dojo recorded the results in the following list of (organized) data:
9, 10, 11, 11, 12, 14, 14, 14
What is the Q1 of this list of data?

Example 2 Solution:

The first step is to find the true location. There are 8 data points, and since we're interested in finding Q1, the percentile of interest is 0.25.
We can then calculate:
true location = (8 - 1) * 0.25 = 1.75.
So, we want to find the 1.75th number in our list of data, which is between 10 (low) and 11 (high). The fraction percent is 0.75, which is the decimal component of the true location.
We can then calculate:
Q1 = 10 + ((11 - 10) * 0.75) = 10.75


Example 3: World Record

On May 25, 2022, 70 year old Naseem Uddin broke the world record for the number of apples smashed in 1 minute by smashing 21 apples. Greatly inspired by this feat, Tyler wanted to try breaking the newly set record. He bought $100 worth of expired apples and began practicing. His good friend, Johnny, recorded each attempt into an organized list as shown below:
3, 4, 5, 5, 6, 8, 9, 9, 10, 10, 10, 10, 11, 12, 13, 14, 14.
What is the Q1 of this list of data?

Example 3 Solution:

We first need to find the true location. There are 17 data points, and since we want to find Q1, the percentile of interest is 0.25.
We can then calculate:
true location = (17 - 1) * 0.25 = 4.0.
The 4th number in the list above is 6 (high and low). The decimal component of the true location is 0, which is used as the fraction percent.
We can then calculate:
Q1 = 6 + ((6 - 6) * 0) = 6


Example 4: Escape Room Part 1

Isabella and Olivia are working through an escape room but can't get out of the third stage. While searching through one of the shelves, Olivia happens upon a slip containing a string of numbers:
0, 1, 39, 60, 72, 99, 100, 127
Isabella suggests that the Q1 of the numbers might be the pass code to the locked door. What is the Q1 of the string of numbers?

Example 4 Solution:

The first step is to find the true location. There are 8 data points, and the percentile of interest is 0.25 since we want to find Q1.
We can then calculate:
true location = (8 - 1) * 0.25 = 1.75.
We want to find the 1.75th number in the list of data, which is between 1 (low) and 39 (high). The decimal component of the true location, 0.75, represents the fraction percent.
We can then calculate:
Q1 = 1 + ((39 - 1) * 0.75) = 29.5


Example 5: Escape Room Part 2

The pass code wasn't Q1, so Isabella and Olivia decide to try finding the Q3 instead. What is the Q3 of the string of numbers?

Example 5 Solution:

The first step is to find the true location. There are 8 data points, and the percentile of interest is 0.75 since we want to find Q3.
We can then calculate:
true location = (8 - 1) * 0.75 = 5.25.
We want to find the 5.25th number in the list of data, which is between 99 (low) and 100 (high). The decimal component of the true location, 0.25, represents the fraction percent.
We can then calculate:
Q1 = 99 + ((100 - 99) * 0.25) = 99.25


Example 6: Chips (with Python)

The Cheap Chips Company tends to be stingy when filling their bags of chips. Oftentimes, it feels like there's more air than chips in the bag. Fed up, Chris buys a case of 12 bags, opens up each bag, and counts the number of chips. He records the number in the list, and ends up with the following data:
11, 11, 11, 12, 12, 13, 13, 13, 13, 13, 13, 15
Below is a DataFrame of this data:

# creating a DataFrame named 'chips' with 'count' column
chips = pd.DataFrame([{'count': 11}, {'count': 11}, {'count': 11}, {'count': 12},
                      {'count': 12}, {'count': 13}, {'count': 13}, {'count': 13},
                      {'count': 13}, {'count': 13}, {'count': 13}, {'count': 15}])
chips
count
011
111
211
312
412
513
613
713
813
913
1013
1115
Creating a DataFrame of Bags of Chips

Chris wants to file a complaint, and decides to include the Q3 in the email to illustrate just how little is in each bag of chips. What is the Q3 of this list of data?

Example 6 Solution:

Hand Calculations
First, let's calculate the true location. There are 13 data points and, since we're interested in finding Q3, the percentile of interest is 0.75.
We can then calculate:
true location = (12 - 1) * 0.75 = 8.25.
So, we want to find the 8.25th number in the list of data, which is between 13 (low) and 13 (high). The decimal component of the true location is 0.25, which will be used as the percentile of interest.
We can then calculate:
Q3 = 13 + ((13 - 13) * 0.25) = 13.
Python Calculations
q3_chips = chips.quantile(0.75)
q3_chips

count 13.0
Name: 0.75, dtype: float64

Finding Q3 Of Chips Data


Example 7: High Fives (with Python)

A group of 9 friends made a bet to see who could get the most high fives, and those that fall within Q1 have to buy the rest of the group dinner. At the end of the day, Robin put the all the results into a DataFrame.
Below is the DataFrame of data:

# creating a DataFrame named 'high_fives' with 'name' and 'number' columns
high_fives = pd.DataFrame([{'name': 'Robin', 'number': 8}, {'name': 'Bianca', 'number': 17}, {'name': 'Sonia', 'number': 11},
                          {'name': 'Jordan', 'number': 15}, {'name': 'John', 'number': 19}, {'name': 'Kirsten', 'number': 19},
                          {'name': 'Hannah', 'number': 32}, {'name': 'Riley', 'number': 39}, {'name': 'Aiden', 'number': 6}])
high_fives
namenumber
0Robin8
1Bianca17
2Sonia11
3Jordan15
4John19
5Kirsten19
6Hannah32
7Riley39
8Aiden6
Creating a DataFrame of the Number of High Fives

Example 7 Solution:

Hand Calculations
Let's first organize our data: 6, 8, 11, 15, 17, 19, 32, 39
The next step is to find the true location. There are 9 data points, and since we want to find Q1, 0.25 is the percentile of interest.
We can then calculate:
true location = (9 - 1) * 0.25 = 2.0.
The 2nd number in the list is 11 (high and low), and the fraction percent is 0.
We can then calculate:
Q3 = 11 + ((11 - 11)* 0) = 11
Python Calculations
high_fives_q1 = high_fives.quantile(0.25)
high_fives_q1

number 11.0
Name: 0.25, dtype: float64

Calculating Q1 of High Fives