Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'expected.': 0.09; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; 'calculates': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'hey': 0.18; 'bit': 0.19; 'not,': 0.20; 'header:User-Agent:1': 0.23; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'list:': 0.30; 'gives': 0.31; 'program,': 0.31; 'easy,': 0.31; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'subject:?': 0.36; 'list': 0.37; 'message-id:@gmail.com': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'new': 0.61; 'back': 0.62; 'william': 0.81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=vQiPzFFMhyijSawPcvx+3ffqcJcH9+kghiAkggxWGac=; b=PqVAPwBGsJPihFYN3WkADO+3K2cc0pg9zNhQ0xCNT/jBlkjdbD2stqLme0EyTv6/qM 8XnxSNYf2NHTNSxcMkw2uS/melDTBMWlA/DvKTODcg3kWzbvFAyaZjlpP/g83XF+JDdM mP8dOEM3+RgdoBgcmkmAFrskNLgNgwOo1fKXozGEods7GdokPEkWlvR2zYLUBGef245Z JQiQw2twTI6jX8fd8pFxQ2UKmD+RiYnfib552PbHFStxCXt7aoEbbiGfRYOTuvP8NUAt eX/Pp4aPmjuhEpOVsqhNi7DHLWgnztc4cD7ouSoW64ixOBDp60hjRSXGP+DEBN0iASri ILlQ== X-Received: by 10.14.9.72 with SMTP id 48mr8179303ees.42.1379375538510; Mon, 16 Sep 2013 16:52:18 -0700 (PDT) Date: Tue, 17 Sep 2013 00:52:17 +0100 From: Jugurtha Hadjar User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How do I calculate a mean with python? References: <571f1251-17a5-44db-a859-17a6d8065151@googlegroups.com> In-Reply-To: <571f1251-17a5-44db-a859-17a6d8065151@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379375545 news.xs4all.nl 15873 [2001:888:2000:d::a6]:36534 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54254 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,