statistics.median() vs statistics.median_low()
statistics.median() and statistics.median_low() are both Python Statistics Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. statistics.median(): Returns the median (middle value) of numeric data. Its syntax is statistics.median(data), and it returns float or int statistics.median_low(): Returns the low median of numeric data (for when there are an even number of values). Its syntax is statistics.median_low(data), and it returns number Example of statistics.median(): statistics.median([1, 3, 5]) # 3
statistics.median([1, 3, 5, 7]) # 4.0 (average of 3 and 5). Example of statistics.median_low(): statistics.median_low([1, 3, 5, 7]) # 3. Read the full references for statistics.median() and statistics.median_low() to see parameters, edge cases, and example code side by side. Other Statistics Module APIs worth comparing: statistics.mean(), statistics.median_high(), statistics.mode(), statistics.multimode(), statistics.stdev(), statistics.pstdev(). Both belong to the Statistics Module category in the Python Reference documentation.