Python Practice › NumPy Programs › Program 93

Variance

EasyNumPy Programs · 93 of 100

Write a NumPy program to calculate the variance of an array.

Advertisement
Input
[2, 4, 4, 4, 5, 5, 7, 9]
Output
4.0

Approach

  1. np.var.

Solution

Python
import numpy as npprint(np.var([2, 4, 4, 4, 5, 5, 7, 9]))
Output
4.0

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs

Leave a Comment