Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97118
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'interpreter,': 0.09; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:version': 0.09; 'python': 0.10; 'python.': 0.11; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'recognise': 0.16; 'subject:Problem': 0.16; 'ways:': 0.16; 'wrote:': 0.16; 'script.': 0.18; '>>>': 0.20; '"",': 0.22; 'assumes': 0.22; 'defined': 0.23; 'help.': 0.23; 'import': 0.24; '(most': 0.24; 'downloaded': 0.24; 'module': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'actual': 0.28; 'question:': 0.29; 'tutorial': 0.29; 'typically': 0.29; 'error.': 0.31; 'getting': 0.33; 'problem': 0.33; 'traceback': 0.33; 'file': 0.34; 'could': 0.35; 'text': 0.35; 'done': 0.35; 'knowledge': 0.35; 'there': 0.36; 'possible': 0.36; 'basic': 0.36; 'modules': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; '(2)': 0.37; 'version': 0.38; '(1)': 0.38; 'mean': 0.38; 'does': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'software': 0.40; 'your': 0.60; 'qualified': 0.63; '2.8': 0.84; '3.4': 0.84; 'michel': 0.84; 'mean.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Problem to calculate the mean in version 3.4 |
| Date | Fri, 25 Sep 2015 09:09:16 +0200 |
| Organization | None |
| References | <F4A60959-BFA5-46CC-B83C-9D50CE2D1D00@yahoo.co.uk> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd9b0b.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.164.1443164969.28679.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443164969 news.xs4all.nl 23749 [2001:888:2000:d::a6]:42027 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97118 |
Show key headers only | View raw
Michel Guirguis wrote: > I have downloaded the version 3.4 and I have a problem to calculate the > mean. The software does not recognise the function mean(). I am getting > the following error. > >>>> mean([1, 2, 3, 4, 4]) > Traceback (most recent call last): > File "<pyshell#4>", line 1, in <module> > mean([1, 2, 3, 4, 4]) > NameError: name 'mean' is not defined > > Could you please help. Is it possible to send me the version that > calculate statistics. The help for the statistics and other modules assumes basic knowledge of Python. I recommend you read the tutorial or any other introductory text on Python before you proceed. Regarding your actual question: before you can use a function you have to import it. There are two ways: (1) Recommended: import the module and use the qualified name: >>> import statistics >>> statistics.mean([1, 2, 3, 4, 4]) 2.8 (2) Import the function. Typically done when you want to use it in the interactive interpreter, not in a script. >>> from statistics import mean >>> mean([1, 2, 3, 4, 4]) 2.8
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Problem to calculate the mean in version 3.4 Peter Otten <__peter__@web.de> - 2015-09-25 09:09 +0200
csiph-web