Run NumPy Online

NumPy Mean, Median, and Standard Deviation

Mean, median, and standard deviation summarize the center and spread of numeric data.

What is NumPy Mean, Median, and Standard Deviation?

Mean, median, and standard deviation summarize the center and spread of numeric data.

Calculate descriptive statistics with NumPy and run the example online.

When should you use it?

  • Perform numerical operations on many values at once.
  • Process arrays, matrices, and scientific data efficiently.
  • Prepare data for data science and machine learning.

Example code

Run code →
main.py
import numpy as np

scores = np.array([72, 81, 85, 90, 92])

print("mean:", np.mean(scores))
print("median:", np.median(scores))
print("std:", round(np.std(scores), 2))

Expected output

mean: 84.0
median: 85.0
std: 7.13

How it works

NumPy calculates each statistic over the entire array by default. The standard deviation describes typical distance from the mean.

Change the values and run the program in the CodeUtility online Python compiler without installing Python locally.

Practice exercises

Modify the runnable example with the exercises below to build understanding beyond copying the result.

  1. Change the input shape and dtype.
  2. Try negative, floating-point, and missing values.
  3. Apply the operation to larger multidimensional arrays and measure performance.
Run in Python IDE →