Interview Q&A / Data Science

BeginnerIn-depth4 min readUpdated 2 Oct 2026

What is the difference between mean, median and mode, and when is the median better?

SHORT ANSWER

The mean is the sum divided by the count, the median is the middle value after sorting, and the mode is the most frequent value. Use the median when the data is skewed or has outliers, like salaries, because one very large value pulls the mean up but barely moves the median.

Explain it simply

All three are ways of answering one question: "What is a typical value here?"

  • The mean (average) is what you get when you add everything up and share it equally. It is like a cricketer's batting average.
  • The median is the person standing in the middle when everyone lines up from smallest to largest.
  • The mode is the value that shows up most often, like the most common shoe size sold in a shop.

When the numbers are spread evenly, all three are close to each other. When a few values are extreme, they disagree, and that is when the choice matters.

Example

Seven people in a small startup earn these salaries, in lakh rupees per year:

4, 4, 5, 6, 7, 8, 50

The 50 is the founder.

  • Mean = (4 + 4 + 5 + 6 + 7 + 8 + 50) / 7 = 84 / 7 = 12 lakh
  • Median = the 4th value in sorted order = 6 lakh
  • Mode = 4 lakh (it appears twice)

If the company advertises "average salary 12 lakh", that is technically true, but six of the seven people earn 8 lakh or less. The median of 6 lakh describes a typical employee much better.

python
import pandas as pd

salaries = pd.Series([4, 4, 5, 6, 7, 8, 50])
print(salaries.mean())    # 12.0
print(salaries.median())  # 6.0
print(salaries.mode().tolist())  # [4]  (mode returns a Series, since there can be ties)

How it works

  • The mean uses every value, so every value has a pull on it. One extreme value can drag it far away.
  • The median only cares about order. If the founder earned 500 lakh instead of 50, the median would still be 6.
  • For an even number of values, the median is the average of the two middle values.
  • The mode is the only one that works for categories, such as the most common city or blood group. A dataset can have no mode or several modes.
  • In a right-skewed distribution (a long tail of large values, like income or house prices), you usually see mean > median. In a left-skewed one, mean < median.

Real-world use

  • Government and survey reports often quote median household income, because a few very rich households distort the mean.
  • Placement reports that show "average package" can be misleading for the same reason; the median package is the more honest number.
  • When you fill missing values in a numeric column, the median is a safer default than the mean if the column is skewed.
  • The mode is used for categorical columns, for example filling a missing "state" with the most common state.

Common mistakes

  • Forgetting to sort before picking the median.
  • Saying the mean is "wrong" for skewed data. It is not wrong; it answers a different question (the total shared equally).
  • Using the mean for categorical data, or assuming there is always exactly one mode.
  • Not checking for outliers before reporting an average.

What to say in the interview

"The mean is the sum divided by the count, the median is the middle value once the data is sorted, and the mode is the most frequent value. The mean is sensitive to outliers because every value contributes to it, while the median only depends on position. So for skewed data like salaries or house prices I would report the median, and I would use the mode for categorical data. For roughly symmetric data without outliers, the mean is fine and all three are close."

Follow-up questions

  • In a right-skewed distribution, which is larger, the mean or the median?
  • How would you fill missing values in a skewed numeric column?
  • What is a trimmed mean and when would you use it?

Go deeper

Read these once the basics above feel easy.

A trimmed mean drops a fixed percentage of the smallest and largest values before averaging. It sits between the mean and the median: it uses more of the data than the median but resists outliers better than the mean. Sports scoring with several judges often removes the highest and lowest score for the same reason.

For grouped data, such as marks recorded in ranges (0-10, 10-20 and so on), you cannot see exact values, so the mean and median are estimated from class midpoints and cumulative frequencies.

#statistics#central-tendency#descriptive-statistics

Related questions

Practise more Data Science questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Data Science quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.