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. So open that up in your editor. It looks like there's one function in here., let's run it.
0:09 I'm just going to right click here and say run and I get a name error on line 13. Okay, let's read what the test says to do
0:21 and see if we can make it so we don't get a name error, so we get a pass here.
0:25 It says calculate the mean, variance and standard deviation of the data array, store the results in m, v and s.
0:33 So this wants us to use the statistics library. So from statistics, import and we can say we're going to import the mean and the variance
0:48 and if we want to put this on another line, we could say stdev. So again, we put parentheses here
0:56 if we want to have our imports go across multiple lines. So here's data, we want to get the mean of it m is equal to the mean of the data,
1:05 v is the variance, v equals variance of data. and s equals standard deviation of data, looks good. Let's run it— bingo, we're good.
1:18 So this is a library that's built into Python and it's good for doing basic statistics.
1:24 So rather than writing your own, take advantage of this because it's there.


Talk Python's Mastodon Michael Kennedy's Mastodon