Two newbie questions

Moshe Zadka moshez at math.huji.ac.il
Wed Jun 14 01:39:35 EDT 2000


On Tue, 13 Jun 2000, Manus Hand wrote:

> Following my own post.  How gauche.
> 
> Anyway, a slightly more legible alternative to get a random number
> between -sys.maxint and sys.maxint:
> 
> import random
> yourNumber = random.randrange(sys.maxint) * random.choice([1, -1])

Note that this is wrong: the chance to get 0 is twice the chance to get 1.

--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list