2/10/26, 5:06 PM Chapter Wise
Statistics module
Statistics Module in Python
The statistics module provides functions for calculating mathematical statistics of numeric
data. It is useful for analyzing datasets in education, research, and data science.
To use it, first import:
import statistics
Mean (Average)
Returns the average of the data.
data = [10, 20, 30, 40, 50]
print([Link](data)) # 30
data2 = [5, 15, 25]
print([Link](data2)) # 15
Median
Returns the middle value when the data is sorted.
data = [10, 20, 30, 40, 50]
print([Link](data)) # 30
data2 = [10, 20, 30, 40]
print([Link](data2)) # 25.0 (average of 20 and 30)
Mode
Returns the most frequently occurring value.
data = [10, 20, 30, 40, 40, 50]
print([Link](data)) # 40
data2 = [1, 2, 2, 3, 3, 3, 4]
print([Link](data2)) # 3
[Link]:8000/articles/?grade=9&subject=21 1/2
2/10/26, 5:06 PM Chapter Wise
Key Takeaways
mean() → Average value
median() → Middle value
mode() → Most frequent value
[Link]:8000/articles/?grade=9&subject=21 2/2