#
Python 3, an illustrated tour Transcripts

Chapter: Numbers

Lecture: Walk-through: Statistics

Login or
purchase this course
to watch this video and the rest of the course contents.

0:00
In this video we're going to look at stat test.

0:02
So open that up in your editor.

0:05
It looks like there's one function in here., let's run it.

0:08
I'm just going to right click here and say run

0:11
and I get a name error on line 13.

0:15
Okay, let's read what the test says to do

0:20
and see if we can make it so we don't get a name error, so we get a pass here.

0:24
It says calculate the mean, variance and standard deviation of the data array,

0:29
store the results in m, v and s.

0:32
So this wants us to use the statistics library.

0:35
So from statistics, import and we can say

0:42
we're going to import the mean and the variance

0:47
and if we want to put this on another line, we could say stdev.

0:53
So again, we put parentheses here

0:55
if we want to have our imports go across multiple lines.

0:58
So here's data, we want to get the mean of it

1:01
m is equal to the mean of the data,

1:04
v is the variance, v equals variance of data.

1:08
and s equals standard deviation of data, looks good.

1:13
Let's run itâ€” bingo, we're good.

1:17
So this is a library that's built into Python

1:20
and it's good for doing basic statistics.

1:23
So rather than writing your own, take advantage of this because it's there.