Hands-On Guide: Calculating Average, Median, Mode, Standard Deviation, Variance, and Interquartile Range
☰Fullscreen
Table of Content:
Scenario
The following table lists the marks of students. Find the average, median, mode, standard deviation, variance, and Interquartile range mark of the class.
| Name | Marks |
|---|---|
| A | 90 |
| B | 86 |
| C | 70 |
| D | 95 |
| E | 95 |
| F | 95 |
| G | 95 |
Solution in Python
from scipy import stats import numpy as np import statistics data ={"A": 90,"B": 86,"C":70,"D":95,"E":95,"F":95,"G":95} values = list(data.values()) print("Mean") print(np.mean(values)) print("Median") print(np.median(values)) print("Mode") print(statistics.mode(values)) print("Standard Deviation") print(np.std(values)) print("Variance") print(np.var(values)) print("range") print(stats.iqr(values))```