A shop owner says her customers spend about 500 rupees on a visit. A company says its staff earns about 66,900 rupees a month. Each sentence squeezes a whole list of numbers into one. That single number is called a measure of central tendency, and picking the right one decides whether the sentence is honest or misleading.
There are three main measures: the mean, the median and the mode. They often give different answers for the same data, and each is right in some cases and wrong in others. In data science you use them in the first hour with any dataset, to understand its typical value, before doing anything advanced.
This tutorial explains all three in plain steps. You will learn how to calculate each one for a plain list, a discrete frequency table and a continuous class table, how to avoid the usual mistakes, how to choose between them, and how to get the same answers in Python in a few lines.
Central tendency is a single value that describes the centre, or the typical value, of a set of data. It tells you where the data tends to gather. Other names are average and measure of central location.
Take the marks of five students: 72, 65, 81, 75 and 83. You can say that the class did well, but one number is easier to compare. If another class has a typical mark of 70, you can compare the two groups at once.

How you calculate depends on how the data is arranged. You will meet three layouts.
| Series | What it looks like |
|---|---|
| Individual series | A simple list of values, such as 72, 65, 81, 75, 83 |
| Discrete series | Each value appears with its frequency, which tells you how many times it occurs. Example: value 10 occurs 2 times |
| Continuous series | Values are grouped into classes, such as 10 to 20, with a frequency for each class |
The five marks add up to 376. Dividing by 5 gives 75.2, which is the mean. Sorted, the marks are 65, 72, 75, 81, 83, and the middle one is 75, which is the median. No mark repeats, so this list has no mode.

The mean is what most people call the average. You add up all the values and divide by how many there are.
Mean = sum of all values divided by the number of values. For the marks above, 376 divided by 5 is 75.2.

When values repeat, multiply each value by its frequency, add the results, and divide by the total frequency. Write this as: mean = sum of f times x, divided by N. Here x is the value, f is its frequency, and N is the total of all frequencies. Note that N is not the frequency of one value. The live page calls N simply Frequency, which is misleading.

Example: the values are 10, 20, 30, 40 and 50, with frequencies 2, 5, 6, 9 and 4.
| Value x | Frequency f | f times x |
|---|---|---|
| 10 | 2 | 20 |
| 20 | 5 | 100 |
| 30 | 6 | 180 |
| 40 | 9 | 360 |
| 50 | 4 | 200 |
| Total | N = 26 | 860 |
Mean = 860 divided by 26 = 33.08 (to two decimal places). The live page says 33.07. The exact value is 33.0769, so rounding gives 33.08.
For classes, first find the midpoint of each class. Add the lower and upper limit, and halve it. Then use the same method with the midpoint as x. The result is an estimate, because you no longer know the exact values inside each class.

Example: the classes are 10 to 20, 20 to 30, 30 to 40, 40 to 50 and 50 to 60, with the same frequencies 2, 5, 6, 9 and 4.
| Class | Midpoint x | Frequency f | f times x |
|---|---|---|---|
| 10 to 20 | 15 | 2 | 30 |
| 20 to 30 | 25 | 5 | 125 |
| 30 to 40 | 35 | 6 | 210 |
| 40 to 50 | 45 | 9 | 405 |
| 50 to 60 | 55 | 4 | 220 |
| Total | N = 26 | 990 |
Mean = 990 divided by 26 = 38.08. The live page says 38.07, and the exact value is 38.0769.
The median is the middle value when the data is sorted from smallest to largest. Half the values lie below it and half lie above.
Odd example: 34, 41, 29, 52, 41, 47, 38, 60, 44. Sorted: 29, 34, 38, 41, 41, 44, 47, 52, 60. N is 9, the position is (9 plus 1) divided by 2 = 5, and the 5th value is 41. So the median is 41.
Even example: add one more value, 50, to get 10 values. Sorted: 29, 34, 38, 41, 41, 44, 47, 50, 52, 60. N is 10, so the middle sits between the 5th and 6th values, which are 41 and 44. The median is (41 plus 44) divided by 2 = 42.5. The live page writes N as 9 in this example, which is wrong. The data has 10 values.
Build a cumulative frequency column, which is a running total of the frequencies. Find the first cumulative frequency that is greater than or equal to N divided by 2. The value on that row is the median.
Example (my own numbers): values 10, 20, 30, 40, 50 with frequencies 4, 7, 12, 9, 6.
| Value | Frequency | Cumulative frequency |
|---|---|---|
| 10 | 4 | 4 |
| 20 | 7 | 11 |
| 30 | 12 | 23 |
| 40 | 9 | 32 |
| 50 | 6 | 38 |
N is 38, so N divided by 2 is 19. The first cumulative frequency that reaches 19 or more is 23, on the row for value 30. The median is 30. Expanding the list and taking the middle two values, the 19th and 20th, gives 30 and 30, so the answer holds.

Here you first find the median class, then use a formula to place the median inside it.

Example from the original page: N = 170, so N divided by 2 is 85. The median class is 30 to 40. The cumulative frequency before it, Cf, is 59, the class frequency f is 50, and h is 10. Median = 30 plus ((85 minus 59) divided by 50) times 10 = 30 plus 5.2 = 35.2.

The mode is the value that appears most often. It is the only one of the three that also works for words and categories, such as the most common shirt size or the most popular course.
Count how often each value occurs. The one with the highest count is the mode. Example: 2, 1, 3, 6, 6, 5, 1, 2, 2, 3. The value 2 appears three times, more than any other, so the mode is 2.
A list can have more than one mode. In 1, 2, 2, 3, 3, 4, both 2 and 3 appear twice, so the data is bimodal. If no value repeats, there is no mode.
Look at the frequency column. The value with the largest frequency is the mode.
Find the modal class, which is the class with the highest frequency. Then use this formula:
Example from the original page: the modal class is 30 to 40, so l is 30 and h is 10. The page works out to 30 plus 10 times (5 divided by 10) = 35. The formula is correct on the live page.
This is the part most tutorials skip, and it matters more than the formulas. The mean uses every value, so one very large value drags it upwards. The median ignores how large the extremes are, so it stays steady.
Here is a worked case. Ten staff earn these monthly salaries in thousands of rupees: 22, 25, 27, 28, 30, 31, 33, 35, 38 and 400, where the last is the owner.
| Measure | All ten people | Without the owner |
|---|---|---|
| Mean | 66.9 | 29.89 |
| Median | 30.5 | 30 |
One outlier lifted the mean from about 30 to 66.9. Almost nobody in the group earns that. The median moved from 30 to 30.5. If a company says its staff earns 66,900 a month on average, it is true, and it is also misleading. The median tells the fairer story.
| Measure | Use it when | Watch out for |
|---|---|---|
| Mean | Data is fairly even, with no extreme values, and you need a number you can use in further calculations | Outliers pull it away from the typical value |
| Median | Data is skewed or has outliers, such as incomes, house prices or delivery times | It ignores how large the extremes are |
| Mode | Data is in categories, or you want the most common value | There can be none, one or many |
A habit worth building: calculate the mean and the median together. If they are close, the data is fairly balanced. If they are far apart, you have skew or outliers, and you should look at the data before trusting either.
You rarely do this by hand in real work. The statistics module comes with Python, and pandas gives the same answers for a column of data. I ran the code below and the output is real.
Use mode for the first mode only, and multimode when a list may have more than one. The module also has other averages. The geometric mean suits growth rates, and the harmonic mean suits rates such as speed. For example, driving the same distance at 40 and 60 kilometres an hour gives a harmonic mean of 48, which is the true average speed. The plain mean of 50 would be wrong. These two are given by geometric_mean and harmonic_mean in the same module. For grouped data, there is median_grouped, which takes the class width as its interval argument.
| Mistake | Fix |
|---|---|
| Using N as the frequency of one value | N is the total of all frequencies |
| Forgetting to sort before finding the median | Always sort first |
| Using the position as the answer | The position tells you where to look. The median is the value at that position |
| Using class limits instead of midpoints for the mean | Use the midpoint of each class |
| Taking the lower limit of the wrong class in the median formula | Use the median class, which is the first class where Cf reaches N divided by 2 |
| Reporting the mean for skewed data without checking | Compare it with the median |
| Rounding too early | Keep full decimals and round the final answer |
Answers: 1) Mean is 91 divided by 6 = 15.17 and the sorted list 11, 12, 15, 15, 18, 20 gives median (15 plus 15) divided by 2 = 15. 2) Modes are 4 and 6. 3) Sum of f times x is 15 plus 40 plus 45 = 100, N is 10, so the mean is 10. 4) The median, because the 300 is an outlier that pulls the mean up. These answers are my calculations, so please recheck them before publishing.
Mean, median and mode look simple, but choosing between them is a real skill. Practise on your own data. Calculate the mean and median side by side, and notice when they disagree. That habit will save you from many wrong conclusions in data science.