Re: generate random digits with length of 5

2008-09-29 Thread sotirac
On Sep 28, 5:22 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 28, 4:08 pm, Michael Ströder <[EMAIL PROTECTED]> wrote: > > > > > Gary M. Josack wrote: > > > Aaron "Castironpi" Brady wrote: > > >> On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: > > > >>> Wondering if the

Re: generate random digits with length of 5

2008-09-29 Thread dusans
On Sep 29, 12:06 am, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:54 pm, "Aaron \"Castironpi\" Brady" > > > > > > <[EMAIL PROTECTED]> wrote: > > On Sep 28, 3:44 pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > > On Sep 28, 3:11 pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > > > > > Chris

Re: generate random digits with length of 5

2008-09-28 Thread bearophileHUGS
Tim Chase: > I suspect that the zfill responses don't have the property of equally > distributed "randomness", as the first digit may more likely be a zero. This code I have shown before: str(randrange(10)).zfill(5) If the numbers are equally distributed in [0, 9], then the leading zeros

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 4:02�pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > Wondering if there is a better way to generate string of numbers with > > a length of 5 which also can have a 0 in the front of the number. > > If you want to resample the same digit multiple times, either of these > two will do: > > �>>>

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 3:54�pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:44�pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > > > > > On Sep 28, 3:11 pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > > > > Chris Rebert wrote: > > > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 4:08 pm, Michael Ströder <[EMAIL PROTECTED]> wrote: > Gary M. Josack wrote: > > Aaron "Castironpi" Brady wrote: > >> On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: > > >>> Wondering if there is a better way to generate string of numbers with > >>> a length of 5 which also can hav

Re: generate random digits with length of 5

2008-09-28 Thread Michael Ströder
Gary M. Josack wrote: > Aaron "Castironpi" Brady wrote: >> On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: >> >>> Wondering if there is a better way to generate string of numbers with >>> a length of 5 which also can have a 0 in the front of the number. >>> >>> >>> random_number = random

Re: generate random digits with length of 5

2008-09-28 Thread Tim Chase
Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. If you want to resample the same digit multiple times, either of these two will do: >>> from random import choice >>> ''.join(str(choice(range(10))) for _ in

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 3:44 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:11 pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > > > > > Chris Rebert wrote: > > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > > > >> Wondering if there is a better way to generate string of numb

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 3:11�pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > Chris Rebert wrote: > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > > >> Wondering if there is a better way to generate string of numbers with > >> a length of 5 which also can have a 0 in the front of the

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Gary M. Josack wrote: Aaron "Castironpi" Brady wrote: On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,

Re: generate random digits with length of 5

2008-09-28 Thread bearophileHUGS
sotirac: > random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 elements But note that's without replacement. So if you want really random numbers you can do this: >>> from string import digits >>> from random import choice >>> "".join(choice(digits) for d in xrange(5)) '93898' If

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Aaron "Castironpi" Brady wrote: On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Chris Rebert wrote: On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: > Wondering if there is a better way to generate string of numbers with > a length of 5 which also can have a 0 in the front of the number. > > >  random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 > elements >  code = 'this is

Re: generate random digits with length of 5

2008-09-28 Thread Chris Rebert
On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > Wondering if there is a better way to generate string of numbers with > a length of 5 which also can have a 0 in the front of the number. > > > > random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 > elements >

generate random digits with length of 5

2008-09-28 Thread sotirac
Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 elements code = 'this is a string' + str(random_number[0]) + str(random_number[1]) + str(ra