Problem to calculate the mean in version 3.4

Paul Rubin no.email at nospam.invalid
Fri Sep 25 03:12:05 EDT 2015


Michel Guirguis <guirguismichel at yahoo.co.uk> writes:
>>>> mean([1, 2, 3, 4, 4])
> Traceback (most recent call last):...
> NameError: name 'mean' is not defined

Before you can use that function, you have to import the statistics
module, e.g.:

    >>> import statistics
    >>> statistics.mean([1,2,3,4,4])   

or

    >>> from statistics import mean
    >>> mean([1,2,3,4,4])



More information about the Python-list mailing list