Content · Programming · Python

Python Understand Average, Median, Variance, and Distribution

Interpret the mean, median and spread before drawing conclusions from a dataset.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

Interpret the mean, median and spread before drawing conclusions from a dataset.

What You Will Learn


The mean uses all observations and can be pulled by outliers. The median is the middle ordered value and is often more robust to extremes. Variance and standard deviation describe dispersion, but sample and population formulas differ. Always state the unit and sample being measured.

For floating-point results, remember that stored values are approximations. Rounding a displayed value does not change the exact value used by later calculations.

Step-by-Step Example


The example below makes the behavior visible with small input values that you can change safely.

import statistics

salaries = [30, 32, 35, 38, 200]
print(statistics.mean(salaries))
print(statistics.median(salaries))
print(round(statistics.pstdev(salaries), 2))

How the Example Works


  • The imports provide the standard-library tools used in the demonstration: statistics.
  • The variable salaries holds the result of [30, 32, 35, 38, 200]. Later lines use that value or inspect how it changes.
  • The print() calls make the return values or state visible so you can compare them with the explanation and check your prediction.

Expected output from the example:

67
35
66.56

When You Would Use This


This operation can support measurements, numeric reports, simulations, or input validation. Choose integer operations when exact integer answers are required, and check floating-point rounding when displaying measured values. Validate units and input domains before using the result in a calculation.

Practice: Modify the Code


Remove the outlier and compare the mean and median before and after.

Verify the changed output against the behavior described above, including the relevant invalid or boundary case.

For complete parameters and version details, consult the official Python documentation.

Common Beginner Mistakes


  • Using sample standard deviation and population standard deviation interchangeably.
  • Reporting only the mean for a heavily skewed dataset with an outlier.

Key Takeaways


  • Interpret the mean, median and spread before drawing conclusions from a dataset.
  • The mean uses all observations and can be pulled by outliers.
  • Apply this operation only after checking the assumptions and input conditions shown in the example.
Share this resourceSend this page to someone who may find it useful.