Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99218

Re: anyone tell me why my program will not run?

From Pavel Volkov <sailor@lists.xtsubasa.org>
Newsgroups comp.lang.python
Subject Re: anyone tell me why my program will not run?
Date 2015-11-21 20:15 +0300
Message-ID <mailman.43.1448126112.2291.python-list@python.org> (permalink)
References <1737402a-2f4d-440a-abd7-6cc500f673e1@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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