samedi 24 septembre 2016

random.randrange does not seem quite random

I am pretty new to python so i dont know many things. So lets say i got this piece of code

for i in range(10000):
n = random.randrange(1, 1000**20)
ar.append(n)
print(n)

The smallest number i get out of the 10000 is always 3-4 digits smaller than 1000^20 in this particular example the smallest numbers are

2428677832187681074801010996569419611537028033553060588
8134740394131686305349870676240657821649938786653774568
44697837467174999512466010709212980674765975179401904173
50027463313770628365294401742988068945162971582587075902
61592865033437278850861444506927272718324998780980391309
71066003554034577228599139472327583180914625767704664425
90125804190638177118373078542499530049455096499902511032
100371114393629537113796511778272151802547292271926376588

i have tried multiple ranges on multiple occasions and every time i get the same results.Maybe i am doing something wrong?




Aucun commentaire:

Enregistrer un commentaire