DSM
50 XP
25 minsBeginner50 XP

Mean, Median, and Mode

A recruiter tells you the 'average salary' on a team is $180,000. Sounds incredible — until you learn the team is four junior analysts on $60,000 and one founder on $660,000. Nobody actually earns the 'average'. That single number, honestly calculated, paints a completely false picture. The fix isn't more math; it's knowing which average to use. By the end of this lesson you'll pick the right one every time — and spot when someone's picked the wrong one to mislead you.

What you'll learn

  • Compute the mean, median, and mode of a small dataset
  • Explain what each measure actually represents
  • Predict how an outlier moves the mean but not the median
  • Choose the right measure for skewed vs. symmetric data
  • Recognise when a reported 'average' is misleading

What

A measure of central tendency is a single number that summarises 'the typical value' of a column. There are three: the mean (add up and divide), the median (the middle value when sorted), and the mode (the most frequent value).

Why

You can't eyeball a thousand numbers. Central tendency compresses a whole column into one representative value — the first thing you compute about any numeric variable. But the three measures disagree when data is skewed, and choosing wrong produces confident, misleading conclusions.

Where it's used

Every summary statistic, dashboard, and report. Average order value, median house price, the most common product size — all are central-tendency choices made (well or badly) every day.

Where this runs in production

ZillowHouse prices are reported as medians

Property sites quote the median home price, not the mean, because a handful of mansions would drag the mean far above what a typical home costs. The median resists those extremes.

GlassdoorSalary bands lean on the median

A few executive salaries inflate the mean pay for a role. Reporting the median gives job-seekers a truer sense of what most people in that role actually earn.

ZaraThe mode drives stock decisions

For clothing sizes, the most common size sold — the mode — matters more than any average. You can't stock a 'mean' shirt size; you stock more of the size people buy most.

Theory

The core ideas, in plain language.

Central tendency answers one question: if I had to describe this whole column with a single number, what would it be? Three answers exist, and they mean different things. Knowing all three — and when they disagree — is what separates a careful analyst from someone who just types 'average'.
Key Concept
The three measures

Mean — add all values and divide by how many there are; the 'balance point' of the data. Median — sort the values and take the middle one (or the average of the two middle ones); the 50th-percentile value. Mode — the value that appears most often; the only measure that works for categories, not just numbers.

The mean uses every value, which is its strength and its weakness. Because it adds everything up, one extreme value pulls it hard — the $660k founder dragged a team of $60k earners up to a $180k 'average'. The mean is the balance point: put the numbers on a see-saw and the mean is where it tips level.
Analogy: The median is the person standing in the middle

Line up everyone on the team from lowest salary to highest and walk to the person in the exact middle of the line. Their salary is the median. It doesn't matter whether the person at the far end earns $660k or $6 million — the middle of the line doesn't move. That's why the median shrugs off outliers: it cares about position, not size. For our team, the median salary is $60k — a far more honest 'typical'.

salaries = [60, 60, 60, 60, 660]   # thousands
mean   = sum(salaries) / 5   # 900 / 5 = 180
sorted = [60, 60, 60, 60, 660]
median = sorted[2]           # middle value = 60
# The mean says 180. The median says 60. The median is honest here.

Same five numbers, two very different summaries. The mean (180) is inflated by one large value; the median (60) reflects what four of the five people actually earn. When they disagree this much, the data is skewed.

The mode is the most frequent value. It's the only measure that works on categories — you can't take the 'mean' of favourite colours, but you can find the most common one. For numbers, the mode is useful when repetition matters: the most common shoe size, the most frequent star rating. A dataset can have one mode, several, or none.
Watch out
The mean lies on skewed data

When data is skewed — meaning most values cluster on one side while a few large values stretch a long tail out the other way (income, house prices, city populations, wait times) — those extreme values drag the mean toward the tail. You'll study this shape in depth next lesson; for now, just know that in those cases the mean overstates the 'typical' value, and the median is the honest choice. Whenever someone quotes an average for money or size, ask: mean or median? The gap between them reveals the skew.

One habit ties this together: never report a single 'average' without knowing the shape of the data behind it. If the mean and median are close, the data is fairly symmetric and either is fine. If they're far apart, the data is skewed and you must choose deliberately — and say which one you used.
Visual Learning

See the concept, then explore it.

Three Ways to Say 'Typical'

Click each measure to see how it's computed, what it resists, and when to reach for it. The right choice depends on the shape of your data.

Select a type to see its full definition, operations, and data science usage.

Worked Examples

Watch it built up, one line at a time.

Very EasyCompute the mean

Five customers rated a coffee shop: 4, 5, 3, 4, 4 stars. What's the mean rating?

Step 1 of 2

The mean is the total of all values divided by how many there are. First add them: 20.

Code
01ratings = [4, 5, 3, 4, 4]
02total = 4 + 5 + 3 + 4 + 4 # 20
Practice Coding

Your turn — write the code.

Your task

Compute the mean and median of a small salary list by hand-coding the logic (no libraries). The list is deliberately skewed by one large value, so compare your two answers and see which is the honest 'typical'. Fill the blanks and run it.

Expected output
Mean: 91.7
Median: 50.5
Honest typical value: 50.5

Write your solution in the editor on the right, then hit Run.

Exercises

Prove it. Reach 80% to complete the lesson.

Mastery Gate0% / 80% required
Easy0/2 solved

How do you calculate the median of a sorted list of numbers?

Which measure of central tendency can be used for a categorical variable like 'favourite colour'?

Medium0/3 solved

A dataset of incomes has a mean of $85,000 and a median of $52,000. What does this gap tell you?

ScenarioA landlord advertises that the 'average rent' on his properties is low, quoting the mean. Most of his flats are expensive, but he owns one tiny, nearly-free storage unit he counts as a 'property'.

Why is his mean misleading, and what would you ask for?

Find the mode: given a list of shoe sizes, print the size that appears most often. Hint: use max(set(sizes), key=sizes.count).

Counts frequency:Uses list.count to find how often each size appears.
Returns the mode:Prints 8, the size that appears three times.
Hard0/1 solved
ScenarioYou're reporting a team's productivity: tasks completed per person this week were 8, 9, 7, 8, 9, 8. Your manager asks whether to report the mean, median, or mode.

What's the best recommendation and why?

Complete 80% more exercises to unlock.
Interview Prep

How this shows up in real interviews.

When would you use the median instead of the mean?

Show model answer

I use the median when the data is skewed or has outliers, because the median is robust — it's just the middle value, so extreme values don't drag it around. Money is the classic case: incomes, house prices, and order values usually have a long right tail where a few huge values inflate the mean above what a typical case looks like. Reporting the median there gives an honest 'typical' number. The mean is better when the data is roughly symmetric with no wild outliers, or when I specifically need totals and rates, since the mean times the count gives the sum and the median can't. A quick diagnostic I rely on: if the mean and median are far apart, the data is skewed and I lean on the median; if they're close, the data is fairly symmetric and either works.

What is the mode, and when is it more useful than the mean or median?

Show model answer

The mode is the value that appears most frequently in the data. It's uniquely useful in two situations. First, for categorical data — you can't average favourite colours or product categories, but you can find the most common one, so the mode is the only central-tendency measure that applies. Second, for discrete numeric data where frequency is the actual business question: a clothing retailer cares about the most common size sold because they stock by size, not by an 'average' size that might not even exist. The mode's limitations are that a dataset can have several modes or none, and it ignores the magnitude of values, so for continuous quantities like salary I'd usually prefer the median. I think of it as: mode for 'what's most common', median for 'what's typical' on skewed numbers, mean for 'what's the balance point' on symmetric numbers.

A stakeholder shows you a chart where the 'average' looks suspiciously high. How do you investigate whether it's misleading?

Show model answer

My first move is to ask which average it is — mean or median — because that word hides the most common trick. If it's the mean, I compare it to the median: a large gap tells me the distribution is skewed and a few extreme values are inflating the mean, so the 'average' overstates the typical case. I'd then look at the actual distribution, ideally a histogram, to see the shape and spot outliers directly. I also check the unit of observation and whether outliers are real or errors, drawing on data-quality thinking — a single mis-entered value or a legitimate but rare whale can both blow up a mean. Finally I consider whether the mean is even the right summary for the decision at hand; for something like typical customer spend I'd report the median and call out the outliers separately, rather than let one number quietly mislead. The goal is to make the summary match the reality of the data, not just recompute it.

Common Mistakes to Avoid

1) Reporting the mean on skewed data (money, sizes, wait times) where the median is honest. 2) Forgetting to sort before taking the median — the middle of an unsorted list is meaningless. 3) On an even-sized list, taking one middle value instead of averaging the two. 4) Trying to compute a mean or median of categories — only the mode applies there. 5) Quoting 'the average' without saying whether it's the mean or median, which hides skew.

Ask the AI Tutor

Try these prompts in the AI Tutor panel: • 'Give me a list of numbers and quiz me on its mean, median, and mode.' • 'ELI5: why does an outlier move the mean but not the median?' • 'Show me a skewed dataset and ask which average to report.' • 'Give me a real headline that misuses the word average and let me spot the trick.' • 'Interview mode: ask me when to use median over mean.'

Glossary

Central tendency — a single value summarising the 'typical' value of a variable. Mean — the sum of values divided by the count; the balance point. Median — the middle value of the sorted data; robust to outliers. Mode — the most frequent value; the only measure for categories. Outlier — a value far from the rest that pulls the mean. Skew — an asymmetric distribution where one tail is longer, separating mean from median. Robust — a statistic that resists the influence of outliers (like the median).

Recommended Resources

• Book: 'How to Lie with Statistics' by Darrell Huff — its chapter on averages is the classic on mean-vs-median trickery. • Practice: find any news article quoting an 'average' salary or price and ask whether the median would tell a different story. • Reference: skim the pandas methods .mean(), .median(), and .mode() to preview how you'll compute these on real columns. • Next in DSM: you can summarise a column's centre — next you'll learn to read its whole shape with distributions.

Recap

✓ Central tendency summarises a column as one 'typical' value — mean, median, or mode. ✓ The mean adds everything and divides; it's the balance point but is dragged by outliers. ✓ The median is the middle of the sorted data; it resists outliers, so it's honest on skewed data like money. ✓ The mode is the most frequent value and the only measure that works on categories. ✓ A large gap between mean and median signals skew — choose the median and say which measure you used. Next up: Distributions — An Intuition. A single 'typical' value hides how the data spreads out around it. Next you'll learn to read the whole shape of a column — its spread, peaks, and skew — the visual grammar that all data exploration is built on.

scratchpad — preview this lesson's challenge anytime
central_tendency.pyPython
Ready
Output

Run your code to see the output here.