Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26594
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'syntax': 0.03; 'interpreter': 0.04; 'subject:IDLE': 0.04; 'subject:Python': 0.05; 'expressions': 0.07; 'python': 0.09; '22,': 0.09; 'calculating': 0.09; 'highlighting': 0.09; 'pressing': 0.09; 'script,': 0.09; 'subject:Getting': 0.09; 'def': 0.10; 'properly': 0.15; '24,': 0.16; '37,': 0.16; '64,': 0.16; '66,': 0.16; 'does;': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'guessing': 0.16; 'idle.': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'slash': 0.16; 'subject: \n ': 0.16; 'subject:started': 0.16; 'wrote:': 0.17; 'shell': 0.18; '>>>': 0.18; 'written': 0.20; '2.x': 0.22; 'default,': 0.22; 'runs': 0.22; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'looks': 0.26; 'wrote': 0.26; 'replace': 0.27; "doesn't": 0.28; 'division': 0.29; 'received:192.168.1.3': 0.29; 'restart': 0.29; "i'm": 0.29; 'function': 0.30; 'received:84': 0.32; 'print': 0.32; 'idle': 0.33; 'right?': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'replaced': 0.35; "won't": 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; "didn't": 0.36; 'subject:with': 0.36; 'should': 0.36; 'editor': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'gives': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'your': 0.60; "you've": 0.61; "you'll": 0.62; 'between': 0.63; 'skip:= 30': 0.64; 'gave': 0.65; 'forward': 0.66; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:python.org': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=DKcI9XZsuF4A:10 a=9KNvwgKiU5UA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=XpaQHwWCgO1BX15styMA:9 a=wPNLvfGTeEIA:10 a=MHA7dUOdDOmfZv1_:21 a=WjcJeeRe44hq6qdT:21 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Mon, 06 Aug 2012 01:58:28 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Getting started with IDLE and Python - no highlighting and no execution |
| References | <d07282d6-1666-4230-bf46-c0942ef9a390@r7g2000yqr.googlegroups.com> <jvn1vr$ln6$1@dont-email.me> |
| In-Reply-To | <jvn1vr$ln6$1@dont-email.me> |
| 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.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2991.1344214708.4697.python-list@python.org> (permalink) |
| Lines | 69 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344214708 news.xs4all.nl 6905 [2001:888:2000:d::a6]:49724 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26594 |
Show key headers only | View raw
On 06/08/2012 01:09, Rotwang wrote: > On 06/08/2012 00:46, PeterSo wrote: >> I am just starting to learn Python, and I like to use the editor >> instead of the interactive shell. So I wrote the following little >> program in IDLE >> >> # calculating the mean >> >> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11] >> >> def mean(data): >> return sum(data)/len(data) >> >> mean(data1) >> >> >> There is no syntax highlighting and when I ran it F5, I got the >> following in the shell window. >> >> >> >>> ================================ RESTART >> ================================ >>>>> >>>>> >> >> >> Any ideas? > > I don't know what editor you're using or how it works, but I'm guessing > that pressing f5 runs what you've written as a script, right? In that > case the interpreter doesn't automatically print the result of > expressions in the same way that the interactive interpreter does; you > didn't tell it to print anything, so it didn't. > It looks like it's IDLE. > >> If I added print mean(data1), it gave me a invalid syntax >> Which suggests to me that it's Python 3. >> # calculating the mean >> >> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11] >> data2=[1,2,3,4,5] >> >> def mean(data): >> return sum(data)/len(data) >> >> mean(data1) >> print mean(data1) > > If you're using Python 3.x, you'll need to replace > > print mean(data1) > > with > > print(mean(data1)) > > since the print statement has been replaced with the print function in > Python 3. > > If you're instead using Python 2.x then I don't know what the problem > is, but in that case your mean() function won't work properly - the > forward slash operator between a pair of ints gives you floor division > by default, so you should instead have it return something like > float(sum(data))/len(data). >
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Getting started with IDLE and Python - no highlighting and no execution PeterSo <ojlise@gmail.com> - 2012-08-05 16:46 -0700
Re: Getting started with IDLE and Python - no highlighting and no execution Rotwang <sg552@hotmail.co.uk> - 2012-08-06 01:09 +0100
Re: Getting started with IDLE and Python - no highlighting and no execution MRAB <python@mrabarnett.plus.com> - 2012-08-06 01:58 +0100
Re: Getting started with IDLE and Python - no highlighting and no execution Matthew Barnett <mrabarnett@mrabarnett.plus.com> - 2012-08-06 02:01 +0100
Re: Getting started with IDLE and Python - no highlighting and no execution Rotwang <sg552@hotmail.co.uk> - 2012-08-06 02:13 +0100
Re: Getting started with IDLE and Python - no highlighting and no execution PeterSo <ojlise@gmail.com> - 2012-08-05 19:17 -0700
Re: Getting started with IDLE and Python - no highlighting and no execution Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 01:52 +0100
Re: Getting started with IDLE and Python - no highlighting and no execution Terry Reedy <tjreedy@udel.edu> - 2012-08-05 21:32 -0400
Re: Getting started with IDLE and Python - no highlighting and no execution soloflyr@gmail.com - 2012-08-09 06:36 -0700
csiph-web