Descriptive statistics in Python with the statistics module
The statistics module calculates descriptive statistics on a list: mean() is the average, median() the middle value, stdev() the spread. Use import statistics first.
Understanding Descriptive statistics in Python with the statistics module in VCE Data Analytics U4O1
What it does: The statistics module must be imported first. Then statistics.mean() calculates the average of the list. stdev() calculates the sample standard deviation, which describes how spread out the values are around the mean. median() returns the middle value of the sorted list, which is 9. The mean is (2+4+9+11+20) / 5 = 9.2. Range is the highest value minus the lowest value. Adding them does not measure spread. The mean is the total divided by the number of values. sum() adds the values and len() counts them. len() counts the items in the list, so it returns 4. sum(data) is the function that returns the total, 45.
Common mistakes: The list is missing its closing square bracket. It should be data = [4, 8, 6, 5, 7]. print() needs a comma between its arguments. It should be print("Median:", mid).
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 3–37) and word search (Modules 3–62).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
statistics.mean(data)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →