Re: Random Number
From: Elaine Jackson (elainejackson7355_at_home.com)
Date: 03/27/04
- Next message: Roger Binns: "Re: xmlrpc, httplib and SSL"
- Previous message: John Roth: "Re: PEP 318 : Def and Class in expressions"
- In reply to: james blair: "Random Number"
- Next in thread: Paul Rubin: "Re: Random Number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Mar 2004 21:00:18 GMT
The probability that the same number will turn up more than once is
approximately one in two million. If you're still worried, you might want to try
something like this:
>>> import random
>>> randoms=[]
>>> while len(randoms)<5:
x=random.randint(1,100)
if x in randoms:
continue
else:
randoms.append(x)
HTH. BTW it's a lot easier to read "10**10" or "1e10" instead of a big string of
zeros.
Peace
"james blair" <talktojamesblair@yahoo.com> wrote in message
news:a4648036.0403271156.787706e5@posting.google.com...
| Hi
| I am generating a random number using
| random.randint(1,10000000000)
| Whats the possibility that the numbers generated will be same when
| generated by 100 users at the same time?
| Whats the best method to generate random numbers so that they are most
| likely unique??
| Thanks
- Next message: Roger Binns: "Re: xmlrpc, httplib and SSL"
- Previous message: John Roth: "Re: PEP 318 : Def and Class in expressions"
- In reply to: james blair: "Random Number"
- Next in thread: Paul Rubin: "Re: Random Number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|