Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99241
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: anyone tell me why my program will not run? |
| Date | Sun, 22 Nov 2015 13:09:16 -0500 |
| Organization | IISS Elusive Unicorn |
| Lines | 48 |
| Message-ID | <mailman.53.1448215776.2291.python-list@python.org> (permalink) |
| References | <1737402a-2f4d-440a-abd7-6cc500f673e1@googlegroups.com> <43bd9327-3fc8-4264-a62e-f4a62f21e21c@lists.xtsubasa.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de MjTK4mH5oBUguTvXWW/FcQo8EHmwmpjoVQDx9wpsYk7g== |
| 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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '51,': 0.09; 'message-id:@4ax.com': 0.09; 'notes:': 0.09; 'pavel': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:why': 0.09; 'way:': 0.09; 'subject:not': 0.11; 'result.': 0.15; '%s,': 0.16; '>on': 0.16; 'beginning.': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:program': 0.16; 'subject:run': 0.16; 'wrote:': 0.16; 'url:home': 0.18; '>>>': 0.20; '2015': 0.20; '%s"': 0.22; 'sat,': 0.23; 'import': 0.24; 'header:X-Complaints- To:1': 0.26; 'random': 0.29; 'allows': 0.30; 'print': 0.30; 'code': 0.30; 'skip:[ 10': 0.31; 'run': 0.33; 'nov': 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'some': 0.40; 'land': 0.63; 'strange': 0.63; 'more': 0.63; '100': 0.79; 'riley': 0.84; 'subject:tell': 0.84; 'dennis': 0.91; 'received:108': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | adsl-108-79-219-161.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 6.00/32.1186 |
| X-No-Archive | YES |
| 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> |
| Xref | csiph.com comp.lang.python:99241 |
Show key headers only | View raw
On Sat, 21 Nov 2015 20:15:05 +0300, Pavel Volkov
<sailor@lists.xtsubasa.org> declaimed the following:
>On ???????, 21 ?????? 2015 ?. 6:30:02 MSK, Dylan Riley wrote:
>
>Also some more notes:
>
>> heads = int("1")
>> tails = int("2")
>
>Why use this strange initialization? The usual way:
>heads = 1
>tails = 2
>gives the same result.
>
>> while flips != 0:
>> flips -= 1
>
>There's no need to use while and flips variable:
>
>for _ in range(100):
> if random.randint(heads, tails) == heads:
> headscount += 1
> else:
> tailscount += 1
>
>Also, it's good to put import at the beginning.
There's also no need for both headscount and tailscount unless the code
allows for a "coin" to land on its edge.
100 - headscount => tailscount
>>> TRIALS = 100
>>> import random
>>> run = [random.choice([0, 1]) for _ in range(TRIALS)]
>>> print "Heads: %s, Tails: %s" % (sum(run), TRIALS - sum(run))
Heads: 51, Tails: 49
>>>
>>> TRIALS = 200
>>> run = [random.choice([0, 1]) for _ in range(TRIALS)]
>>> print "Heads: %s, Tails: %s" % (sum(run), TRIALS - sum(run))
Heads: 112, Tails: 88
>>>
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
anyone tell me why my program will not run? Dylan Riley <dylan.riley@hotmail.com> - 2015-11-20 19:30 -0800
Re: anyone tell me why my program will not run? Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-20 22:39 -0500
Re: anyone tell me why my program will not run? Chris Angelico <rosuav@gmail.com> - 2015-11-21 16:50 +1100
Re: anyone tell me why my program will not run? Pavel Volkov <sailor@lists.xtsubasa.org> - 2015-11-21 19:57 +0300
Re: anyone tell me why my program will not run? Pavel Volkov <sailor@lists.xtsubasa.org> - 2015-11-21 20:15 +0300
Re: anyone tell me why my program will not run? Larry Hudson <orgnut@yahoo.com> - 2015-11-21 18:44 -0800
Re: anyone tell me why my program will not run? Larry Hudson <orgnut@yahoo.com> - 2015-11-22 13:42 -0800
Re: anyone tell me why my program will not run? John Gordon <gordon@panix.com> - 2015-11-22 16:39 +0000
Re: anyone tell me why my program will not run? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-22 13:09 -0500
csiph-web