How do I calculate a mean with python?

Jugurtha Hadjar jugurtha.hadjar at gmail.com
Mon Sep 16 19:52:17 EDT 2013


On 09/17/2013 12:33 AM, William Bryant wrote:
> Hey I am new to python so go easy, but I wanted to know how to make a program that calculates the maen.
>
> List = [15, 6, 6, 7, 8, 9, 40]
> def mean():
>      global themean, thesum
>      for i in List:
>          thecount = List.count(i)
>          thesum = sum(List)
>      themean = thesum / thecount
>
> Why doesn't this work?
>


Hello, William..

How about you try to execute one bit of your program, and if that works, 
try to add to it.

Try

list = [15, 6]
list.count(1)

And see if what it gives you back is what you expected. If not, why ?



-- 
~Jugurtha Hadjar,



More information about the Python-list mailing list