0% found this document useful (0 votes)
3 views1 page

Python Statistical Measures Code

Uploaded by

Harshit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Statistical Measures Code

Uploaded by

Harshit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Code for Statistical Measures using statistics

Library
import statistics as stats

# Sample data
data = [10, 20, 20, 40, 50, 60, 60, 60, 80]

print("Data:", data)

# ---- Central Tendency ----


print("Mean:", [Link](data))
print("Median:", [Link](data))
print("Mode:", [Link](data))

# ---- Measures of Spread ----


print("Variance:", [Link](data)) # Sample variance
print("Population Variance:", [Link](data)) # Population variance

print("Standard Deviation:", [Link](data)) # Sample SD


print("Population SD:", [Link](data)) # Population SD

# ---- Additional Functions ----


print("Median Low:", stats.median_low(data))
print("Median High:", stats.median_high(data))
print("Median Grouped:", stats.median_grouped(data))

# ---- Harmonic & Geometric Means ----


print("Harmonic Mean:", stats.harmonic_mean(data))
print("Geometric Mean:", stats.geometric_mean(data))

You might also like