Mean and median
Two ways to describe a "typical" value, and when each one is better.
The mean (average) adds all values and divides by how many there are. The median is the middle value after sorting; with an even number of values it is the average of the two middle ones. Both describe a "typical" value, but they react differently to extreme values. One very large salary pulls the mean up a lot, while the median barely moves. That is why house prices and incomes are usually reported with the median.
salaries = [42, 45, 47, 50, 300] # thousands
mean = sum(salaries) / len(salaries)
s = sorted(salaries)
median = s[len(s) // 2]
print(mean, median)The mean is 96.8, but four of five people earn about 45. The median, 47, describes them much better. One outlier (300) dragged the mean up.
For an even count, like [3, 9, 1, 7], sort to [1, 3, 7, 9]; the middle two are 3 and 7, so the median is 5.
sorted(values) makes a new sorted list and leaves the original alone. values.sort() changes the original, which can surprise the rest of your program.