[Tutor] A file containing a string of 1 billion random digits.
Peter Otten
__peter__ at web.de
Mon Jul 19 13:51:06 CEST 2010
bob gailer wrote:
> Check this out:
>
> import random, time
> s = time.time()
> cycles = 1000
> d = "0123456789"*100
> f = open("numbers.txt", "w")
> for i in xrange(n):
> l = []
> l.extend(random.sample(d, 1000))
> f.write(''.join(l))
> f.close()
> print time.time() - s
Note that this is not random. E. g. the start sequence "0"*101 should have a
likelyhood of 1/10**101 but is impossible to generate with your setup.
Peter
More information about the Tutor
mailing list