Exercise

Practice: Centre, Spread and Boxplots by Hand

Questions to solve on paper: mean, median and standard deviation, quartiles by the method of halves, the IQR rule, drawing a boxplot by hand and reading one on small sets of real answers from the 2026 Stack Overflow Developer Survey, and choosing a time margin from the real delays of a flight.

Last updated:


On this practice page we practise on paper the tools of Same Statistics, Different Pictures and Comparing and Relating:
mean, median and standard deviation, quartiles by the method of halves, the IQR rule for outliers, drawing a boxplot by hand and reading one, and choosing a statistic by the decision to be made.
Almost every question is about real answers to the 2026 Stack Overflow Developer Survey (the reduced file, under the Open Database License: Stack Overflow Developer Survey 2026, Stack Exchange, Inc.; licence details).

The number of tools at nine workplaces

The survey asked: “In a typical month over the past year, about how many distinct software tools, platforms, or services did you personally use to do your primary work?”.
Nine respondents from Israel who work in an organization of 500 to 999 employees answered the question.
These are all their answers, in the order of the file:

9, 3, 3, 10, 10, 8, 4, 69, 109,\ 3,\ 3,\ 10,\ 10,\ 8,\ 4,\ 69,\ 10

Question 1. Compute by hand the mean and the median of the nine answers.
Which of the two measures is closer to most of the answers?

Hint

For the median, sort the answers from smallest to largest. With nine values, the value in the middle is the fifth.

Solution

Mean: the answers add up to 9+3+3+10+10+8+4+69+10=1269+3+3+10+10+8+4+69+10=126⁠, so xˉ=1269=14\bar{x}=\frac{126}{9}=14⁠.

Median: in the order 3,3,4,8,9,10,10,10,693,3,4,8,\mathbf{9},10,10,10,69 the fifth value is 9, so the median is 9.

Eight of the nine answers are below the mean of 14; only the answer 69 is above it.
The median of 9 is closer to most of the answers: the answer 69 pulls the mean up, and the median depends only on the order.

Question 2. Compute by hand the standard deviation of the same nine answers, 9,3,3,10,10,8,4,69,109,3,3,10,10,8,4,69,10⁠, whose mean is 14.
Which answer contributes most of the sum of the squared deviations?

Hint

Build a table with three columns: the value, its deviation from the mean, and the squared deviation.
Divide the sum of the squares by n−1=8n-1=8⁠, then take the square root.

Solution
Value xix_iDeviation xi−xˉx_i-\bar{x}Squared deviation
9−525
3−11121
3−11121
10−416
10−416
8−636
4−10100
69553,025
10−416

The deviations add up to zero, and the squares to 3,476. The sample variance is s2=3,4768=434.5s^2=\frac{3{,}476}{8}=434.5⁠, and the standard deviation is s=434.5≈20.8s=\sqrt{434.5}\approx 20.8 tools.

The answer 69 contributes 3,025 of the 3,476, about 87% of the sum.
A standard deviation of about 21 tools is larger than every distance of the other eight answers from the mean (at most 11):
it reflects mainly one answer.

Question 3. These are the nine answers: 9,3,3,10,10,8,4,69,109,3,3,10,10,8,4,69,10⁠.

  1. Find Q1Q_1 and Q3Q_3 by the method of halves, and compute the IQR.
  2. Compute the limits of the IQR rule. Which answers are flagged as outliers?
  3. Draw a horizontal boxplot on an axis from 0 to 70: the box, the median line, the whiskers and the points.
Hint

With nine values the median is the fifth value, and it belongs to neither half:
each half has four values, and the median of four values is the mean of the two middle ones.
A whisker extends to the furthest value still inside the limits.

Solution
  1. In the order 3,3,4,8,9,10,10,10,693,3,4,8,\mathbf{9},10,10,10,69 the lower half is 3,3,4,83,3,4,8⁠, so Q1=3+42=3.5Q_1=\frac{3+4}{2}=3.5⁠; the upper half is 10,10,10,6910,10,10,69⁠, so Q3=10+102=10Q_3=\frac{10+10}{2}=10⁠. IQR=10−3.5=6.5\mathrm{IQR}=10-3.5=6.5⁠.
  2. The upper limit is Q3+1.5⋅IQR=10+9.75=19.75Q_3+1.5\cdot\mathrm{IQR}=10+9.75=19.75⁠, and the lower limit is Q1−1.5⋅IQR=3.5−9.75=−6.25Q_1-1.5\cdot\mathrm{IQR}=3.5-9.75=-6.25⁠. Only 69 lies beyond the limits, so only it is flagged as an outlier.
  3. The box runs from 3.5 to 10, with the median line at 9, close to the right end of the box. The left whisker reaches 3, the smallest value. The right whisker reaches 10, the largest value that is not an outlier; that is also Q3Q_3⁠, so the right whisker has no length. One point at 69, far to the right of the box.

In pandas, quantile(0.25) of the nine answers returns 4, not 3.5, and quantile(0.75) returns 10. pandas interpolates between neighbouring values (explained in Same Statistics, Different Pictures), so on small data the result can differ a little from the method of halves.

Question 4. Suppose that the answer 69 is a typing error, and we drop it.
Eight answers remain: 9,3,3,10,10,8,4,109,3,3,10,10,8,4,10⁠. What happens to the mean, the median and the standard deviation?
Predict before you compute, then compute.

Hint

With eight values the median is the mean of the fourth and fifth values in order.
For the standard deviation, the new mean is 578=7.125\frac{57}{8}=7.125⁠.

Solution
  • Mean: 126−698=578≈7.1\frac{126-69}{8}=\frac{57}{8}\approx 7.1⁠, almost half of what it was (14).
  • Median: in the order 3,3,4,8,9,10,10,103,3,4,\mathbf{8},\mathbf{9},10,10,10 the median is 8+92=8.5\frac{8+9}{2}=8.5⁠, down by only half a tool (from 9).
  • Standard deviation: the sum of the squared deviations from 7.125 is about 72.9, so s=72.97≈10.4≈3.2s=\sqrt{\frac{72.9}{7}}\approx\sqrt{10.4}\approx 3.2⁠, instead of about 20.8.

One extreme answer changed the mean and the standard deviation a great deal, and the median hardly at all.
The same happens in Same Statistics, Different Pictures when a salary of about 32 million dollars is added to the salaries of seven respondents.

Years of experience of ten respondents

Ten respondents from Israel whose highest education is secondary school wrote how many years of professional work experience they have.
These are all their answers, in the order of the file:

2, 20, 1, 1, 11, 10, 26, 4, 8, 32,\ 20,\ 1,\ 1,\ 11,\ 10,\ 26,\ 4,\ 8,\ 3

Question 5.

  1. Find the median, and Q1Q_1 and Q3Q_3 by the method of halves.
  2. Check with the IQR rule which values are flagged as outliers, and draw a horizontal boxplot on an axis from 0 to 30.
  3. Without computing: is the mean larger or smaller than the median? Explain from the picture, then compute the mean and check.
Hint

When the number of values is even, the median is the mean of the two middle values, and every value belongs to one of the halves:
five values in each half.

Solution
  1. In order: 1,1,2,3,4,8,10,11,20,261,1,2,3,4,8,10,11,20,26⁠. The median is 4+82=6\frac{4+8}{2}=6⁠. The lower half is 1,1,2,3,41,1,\mathbf{2},3,4⁠, so Q1=2Q_1=2⁠; the upper half is 8,10,11,20,268,10,\mathbf{11},20,26⁠, so Q3=11Q_3=11⁠.
  2. IQR=11−2=9\mathrm{IQR}=11-2=9⁠, the upper limit is 11+13.5=24.511+13.5=24.5 and the lower one 2−13.5=−11.52-13.5=-11.5⁠. Only 26 lies beyond the limits. In the picture: a box from 2 to 11, a median line at 6, a left whisker to 1, a right whisker to 20 (the largest value that is not an outlier), and a point at 26.
  3. The mean is larger than the median: the right part of the box (from 6 to 11) is longer than the left part (from 2 to 6), the right whisker is long, and there is a point on the right. The large values pull the mean to the right. The computation: xˉ=8610=8.6\bar{x}=\frac{86}{10}=8.6⁠, larger than the median of 6.

In pandas the quartiles of the ten answers are 2.25 and 10.75, close to the hand result but not the same.

Years of coding of twelve respondents

Twelve respondents from Israel who are not employed wrote how many years they have been coding, including education.
These are all their answers, in the order of the file:

10, 6, 25, 4, 15, 7, 6, 36, 45, 12, 10, 1210,\ 6,\ 25,\ 4,\ 15,\ 7,\ 6,\ 36,\ 45,\ 12,\ 10,\ 12

Question 6.

  1. Find the median, and Q1Q_1 and Q3Q_3 by the method of halves. Which values does the IQR rule flag as outliers?
  2. Suppose that we checked the answer 45 and decided to drop it. Compute the quartiles and the limits again for the eleven remaining values. Is another value flagged as an outlier now? Why?
Hint

With twelve values each half has six values, and the median of six values is the mean of the third and the fourth.
With eleven values the median, the sixth value, belongs to neither half.

Solution
  1. In order: 4,6,6,7,10,10,12,12,15,25,36,454,6,6,7,10,10,12,12,15,25,36,45⁠. The median is 10+122=11\frac{10+12}{2}=11⁠. The lower half is 4,6,6,7,10,104,6,6,7,10,10⁠, so Q1=6+72=6.5Q_1=\frac{6+7}{2}=6.5⁠; the upper half is 12,12,15,25,36,4512,12,15,25,36,45⁠, so Q3=15+252=20Q_3=\frac{15+25}{2}=20⁠. IQR=13.5\mathrm{IQR}=13.5⁠, the upper limit is 20+20.25=40.2520+20.25=40.25 and the lower one 6.5−20.25=−13.756.5-20.25=-13.75⁠. Only 45 is flagged as an outlier.
  2. Without 45 the order is 4,6,6,7,10,10,12,12,15,25,364,6,6,7,10,\mathbf{10},12,12,15,25,36 and the median is 10. The lower half is 4,6,6,7,104,6,6,7,10⁠, so Q1=6Q_1=6⁠; the upper half is 12,12,15,25,3612,12,15,25,36⁠, so Q3=15Q_3=15⁠. IQR=9\mathrm{IQR}=9 and the upper limit is 15+13.5=28.515+13.5=28.5⁠. Now 36 lies beyond the limit, so it is flagged as an outlier. The limits depend on the quartiles, and dropping a value moves Q3Q_3 from 20 to 15: the box shrinks, and the limit comes closer. That is why we do not drop values “until there are no outliers”; each flagged value is checked on its own.

In pandas the quartiles of the twelve values are 6.75 and 17.5:
here the difference from the method of halves in Q3Q_3 is larger, because the two values around it, 15 and 25, are far apart.

Reading a boxplot: years of coding by employment status

The survey also asked: “Including any education, how many years have you been coding in total?”.
The figure has one boxplot for each of four employment groups.
On screen you can hover over a box to see its numbers.

Four horizontal boxplots of years of coding, including education: Students, box 3 to 8 with median 5; not employed, box 6 to 20 with median 10; employed, box 10 to 25 with median 15; self-employed, box 10 to 30 with median 20. Each group has points beyond its right whisker.
Answers to "Including any education, how many years have you been coding in total?" by employment status: 24,501 answers in the four groups. Each box runs from the first to the third quartile, the line inside it is the median, the whiskers end at the last answers within 1.5 IQR of the box, and the answers beyond them are drawn as points. Data: Stack Overflow Developer Survey 2026, Stack Exchange, Inc., licensed under ODbL 1.0.

Question 7. Answer from the figure.

  1. What is the median number of years of coding among the students, and among the self-employed?
  2. About what share of the employed have been coding for 25 years or more?
  3. Which group has the largest IQR, and what is it?
  4. The students’ group has an answer of 20 years of coding. Is it drawn as a point beyond the whisker? Check with the IQR rule.
Hint

The box runs from Q1Q_1 to Q3Q_3⁠, and the line inside it is the median.
For item 4, read the students’ Q1Q_1 and Q3Q_3⁠.

Solution
  1. Among the students the median is 5 years, and among the self-employed 20 years.
  2. About a quarter: among the employed Q3=25Q_3=25⁠, and a quarter of the values are greater than or equal to Q3Q_3⁠. In the data it is 25.9%, a little more than a quarter, because many respondents answered exactly 25.
  3. The self-employed: Q1=10Q_1=10 and Q3=30Q_3=30⁠, so IQR=20\mathrm{IQR}=20⁠. For the employed it is 15, for those not employed 14 and for the students 5.
  4. Yes. Among the students Q1=3Q_1=3 and Q3=8Q_3=8⁠, so IQR=5\mathrm{IQR}=5 and the upper limit is 8+1.5⋅5=15.58+1.5\cdot 5=15.5⁠. 20 is greater than 15.5, so the answer is drawn as a point. “Outlier” here means “far from most of the students”: people who study for another degree after years of work can well have been coding for 20 years.

Question 8. Which of the statements follows from the figure?

A: The figure shows that the self-employed group has more respondents than the group of those not employed

The reasoning: the box of the self-employed is wider, so it seems to hold more people.

The mistake: the width of the box is the IQR, a distance on the axis of years of coding, not the number of respondents.
A boxplot does not show how many observations a group has; that is written next to the picture.
In the data the self-employed are indeed more numerous (3,774 against 1,308 not employed), but the figure does not show it:
the same boxes could come from any group sizes.

B: At least half of the self-employed have been coding for 20 years or more

The reasoning: the median of the self-employed is 20. At least half of the values are greater than or equal to the median, so at least half of the self-employed have been coding for 20 years or more.

C: The mean number of years of coding among the employed is 15

The reasoning: the line inside the box is at 15.

The mistake: the line is the median. A boxplot does not show the mean.
The employed have a long right tail and points up to 100 years, so the mean is larger than the median:
in the data it is 17.8.

D: No student has been coding for more than 15 years

The reasoning: the students’ right whisker ends at 15.

The mistake: a whisker ends at the largest value that is not an outlier.
To its right there are points: answers of students who have been coding for more than 15.5 years.
The data have 50 such answers.

Arrival delays: how much time to leave?

We are booking a holiday in Orlando and planning the day of arrival around the landing.
How much time should we leave between the scheduled landing and the next thing in the plan?
To decide, we look at real delays of that flight.

These are the arrival delays, in minutes, of JetBlue flight 1783 from New York (JFK) to Orlando on the first 15 days of July 2013, in the order of the days.
A negative number means an early arrival. Source: the US Department of Transportation on-time data for every flight that left New York in 2013, from the package nycflights13 (public domain, CC0; the flight’s data for the whole year and details of the source and of the selection).

45, 10, −7, −12, 12, −23, −16, 11, −10, −30, 5, 27, 70, −22, 145,\ 10,\ -7,\ -12,\ 12,\ -23,\ -16,\ 11,\ -10,\ -30,\ 5,\ 27,\ 70,\ -22,\ 1

Question 9.

  1. Find the median and the mean, and by the method of halves Q1Q_1 and Q3Q_3⁠. Does the IQR rule flag any value as an outlier?
  2. Suppose that on each of the 15 days we set the next thing in the plan so that we have a margin of mm minutes after the scheduled landing. On how many days would we be late, with a margin of 1 minute (about the median), 4 minutes (about the mean), 30 minutes and 60 minutes?
  3. What would you set in two cases: dinner at a restaurant, which can be postponed by phone, and the last ferry to an island, where missing it means missing the first night? Why do the median and the mean not answer the question?
Hint

With fifteen values the median is the eighth value, and it belongs to neither half:
each half has seven values. In part 2, count the days on which the delay is larger than the margin.

Solution
  1. In order: −30,−23,−22,−16,−12,−10,−7,1,5,10,11,12,27,45,70-30,-23,-22,-16,-12,-10,-7,\mathbf{1},5,10,11,12,27,45,70⁠. The median is 1. The lower half is −30,−23,−22,−16,−12,−10,−7-30,-23,-22,\mathbf{-16},-12,-10,-7⁠, so Q1=−16Q_1=-16⁠; the upper half is 5,10,11,12,27,45,705,10,11,\mathbf{12},27,45,70⁠, so Q3=12Q_3=12⁠. IQR=28\mathrm{IQR}=28⁠, the upper limit is 12+42=5412+42=54 and the lower one −16−42=−58-16-42=-58⁠, so 70 is flagged as an outlier. The sum is 61, so xˉ=6115≈4.1\bar{x}=\frac{61}{15}\approx 4.1⁠: the mean is larger than the median, because the long delays pull it up, and early arrivals cannot be early by as much.
  2. We are late when the delay is larger than the margin. A margin of 1 minute: 7 days (5,10,11,12,27,45,705,10,11,12,27,45,70⁠). A margin of 4 minutes: the same 7 days. A margin of 30 minutes: 2 days (45 and 70). A margin of 60 minutes: 1 day (70).
  3. A margin set by the median or the mean makes us late on almost half of the days: the median describes the typical day, and the question is about the bad days. The decision depends on the cost of being late. For dinner a margin of about Q3Q_3 (a quarter of an hour) is enough, and on the few days when we are late we postpone the booking. For the ferry we look at the high values: on these 15 days even a 30-minute margin would have failed twice, and over the whole year (365 flights) 14.5% of the flights landed more than half an hour late and 4.9% more than an hour late. So for the ferry we leave more than an hour, or prefer an earlier flight.

In pandas the quartiles of the 15 values are −14-14 and 11.5, close to the result by hand.