In this Python 3 programming tutorial, we cover the statistics module. This module is a built-in module that comes with Python’s installation, and it lets you do some basic statistic calculations. These include: Mean (average), median, mode, standard deviation, and variance.

Sample code for this basics series: http://pythonprogramming.net/beginner-python-programming-tutorials/

Python 3 Programming tutorial Playlist:…

how to calculate group interval like

20-30:5 , 30-40:15 , 40-50:25 , 50-60:20 ,60-70:7 , 70-80:8 , 80-90:10 in python

That’s it?

I'm using python version 3.3.3. When I typed the code in IDLE as you did to import statistics, I get an error module saying that there's no such module named "statistics". Should I create a module like that?

Dude literally thank you. It was brief and direct to the point.

thanks.

Hi there guys, I'm dealing with a similar issue : AttributeError: module 'statistics' has no attribute 'mean' I use python 3.7 on win10…any tip & help would be appreciated!

statistics not working in 3.7 in my system. The error is showing as AttributeError: module 'statistics' has no attribute mean. I dont know why this error is showing. I will be glad if you help me out. Anyway thanks for the awsome tutorial.

hey hii,

i am gettting attribute error while doing statistics ..i am using python 3.6.5.

please help me out through this

Hi My teacher what the wrong in this simple code:

from statistics import *

y=[3,5,5,7,8,8]

print(mean(y))

the PC send the following meesage 'ERROR running 'file name' java.ioEOFException'

help me in sorting it out

code:-

a = [int(x) for x in input().split()]

x = statistics.mean(a)

print(x)

o/p:-

5,6,56,556

—————————————————————————

ValueError Traceback (most recent call last)

<ipython-input-15-a764674e360f> in <module>()

—-> 1 a = [int(x) for x in input().split()]

2 x = statistics.mean(a)

3 print(x)

<ipython-input-15-a764674e360f> in <listcomp>(.0)

—-> 1 a = [int(x) for x in input().split()]

2 x = statistics.mean(a)

3 print(x)

ValueError: invalid literal for int() with base 10: '5,6,56,556'

Is this function, work only with number's ? is there any other function to compare letter and to analyses words

I am in love with you

how to bring mouse cursor in python code,

Also how to a Executable file which I can transfer to any PC which does not have python

Please REPLY FAST

How can i calculate mean of a matrix? I want a vector with column means on an output 🙂

doesnt seem that i have statistics module downloaded how do i get it

import statistics

example_list ={2,3,4,5,6,5,445,554,54,5,55}

x = statistcs.mean(example_list)

print(x)

popped out error is:

=== RESTART: C:/Users/KANNAN/AppData/Local/Programs/Python/Python36/ik2.py ===

Traceback (most recent call last):

File "C:/Users/KANNAN/AppData/Local/Programs/Python/Python36/ik2.py", line 3, in <module>

x = statistcs.mean(example_list)

NameError: name 'statistcs' is not defined

ANY one there please help me i am really finding it difficult

well my long term goal, one of them is to innovate and pioneer AI. newer to python and not deep in math, though i have a great gift for math, lets see if i ever make it and how long it takes.

There is an error in statistics.py at the line 590: it should be divided by n and not by n-1. I checked it sice the results of variance in statictics module and in numpy one differ.

thanx alot 🙂 it's really great and helpful

Traceback (most recent call last):

File "C:/Python33/epicthing.py", line 1, in <module>

import statistics

ImportError: No module named 'statistics'

why this is happening? I am using python3.3

can you please tell me how to take multiple inputs from user and find a mean of it.I have tried but I am unable to get the mean of it.import statistics

#x=[2,4,6,8,9,2,4,5,6,7]—–mean for list

x=raw_input()

x_list=x.split(',')

y=statistics.mean(x_list)

print('the mean is ',y)

I am able to split but unable get the mean.

import statistics

example_list = [4,3,65,3,2,5,6,5,3,24,56,9,5]

x = statistics.mean(example_list)

print ('mean is ',x)

Traceback (most recent call last):

File "C:/Users/Ehtesham/Desktop/Python Codes/testing.py", line 1, in <module>

import statistics

File "C:/Users/Ehtesham/Desktop/Python Codesstatistics.py", line 4, in <module>

x = statistics.mean(example_list)

AttributeError: module 'statistics' has no attribute 'mean'

How do I get user input only in integers

I use python 3.3.3 and can't import statistics in my environment because it doesn't exist. what is the module can I use to perform statistics operations?

Quick help for everyone. statistics module is preinstalled with Python 3, in case you dont have it go ahead and "pip install statistics" in the command line. Also, VERY IMPORTANT, do not name your file statistics since the import will be confused and throw the errors of the library not existing and the mean function not existing. If you have done this already just go to your folder where you saved the file, and delete it. An other option is to Save As, with an other name but then dont forget to set the configurator (the python symbol up right) to have the new script you are using. Hope it helps and once again thank you sentdex for this great series!

Hey Sentdex,

I'm using Python version 3.5.1 and I couldn't get the code working.

import statistics

print(statistics.mean([1,2,4]))

Error obtained:

Traceback (most recent call last):

File "statistics.py", line 1, in <module>

import statistics

File "D:learningsPythonyoutube_sentdexstatistics.py", line 2, in <module>

print(statistics.mean([1,2,4]))

AttributeError: module 'statistics' has no attribute 'mean'

I referred the doc and it said introduced in 3.4, hence I assumed it should work for me.

Can you please help?

hello there sentdex,

i have a file which has import values like

import copy as cp

import numpy as np

from scipy import linalg

from ..io.base import _BaseRaw

from ..epochs import _BaseEpochs

from .. import Covariance, EvokedArray, Evoked, EpochsArray

from ..io.pick import pick_types

from .ica import _get_fast_dot

from ..utils import logger

from ..decoding.mixin import TransformerMixin

from ..cov import _regularized_covariance

from ..channels.channels import ContainsMixin

What does these . and .. mean

and when i try to run it in my pc, it gives an error which i think is from the lack of some libraries. is there an easy way to download all related libraries for specific purpose in a single file like anaconda. (This is a file for eeg reading)

How would I code a multi-user survey program that creates a multiple choice test that would then compare the answers of two users and show how similar they are?

invalid syntax

I'am using python 3.4 and it gives says there is no such module and when i tried to install it sys says no such package available ..

ImportError: No module named 'statistics'.

So what version of python are you using that comes with a statistics module?

def run_std(x):

x.sort()

total = 0

tot = 0

for num in x:

total += num

median = total / float(len(x))

print ("The median is %d" % (median))

for num in x:

dev = (num – median)**2

tot += dev

variance = tot / float(len(x))

print ("The variance is %d" % (variance))

std = variance**0.5

print ("The standard deviation is %d" % (std))

print (run_std(example_list))

print (run_std(test_list))

This is the code I made to perform the STD task. Can someone explain to me why my code rounds the number when inserted in the string. For example say the STD is 14.3, if I just tell the code to print std it will give me 14.3, but when the value is inserted into the string it rounds down printing out The standard deviation is 14. Is this something python does automatically and if yes is there a way to make it not perform the rounding action so it prints The standard deviation is 14.3

Traceback (most recent call last):

File "C:UsersSuzanneDocumentsPythonstatistics.py", line 1, in <module>

import statistics

File "C:UsersSuzanneDocumentsPythonstatistics.py", line 5, in <module>

x = statistics.mean(list1)

AttributeError: 'module' object has no attribute 'mean'

plz help :3

Is there another way to find the mean without importing the statistics module?

I had an error Traceback (most recent call last):

File "D:/Sendex/Statistics_Mean.py", line 2, in <module>

import statistics

ImportError: No module named statistics

I got around this by using Pycharm and settings – Project Interpreter – "+" then search for module statistics incase someone else having issues

Traceback (most recent call last):

File "C:/Python34/statistics.py", line 1, in <module>

import statistics

File "C:/Python34statistics.py", line 5, in <module>

x = statistics.stdev(example_list)

AttributeError: 'module' object has no attribute 'stdev'

>>>

Good, thanks. However in the future you might want to include a short background on such math/stats topics to help people to understand just why this is interesting, e.g. relate to the grading bell curve, etc.