random.randrange does not seem quite random
<p>I am pretty new to python so i dont know many things.
So lets say i got this piece of code </p>

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

<p>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</p>

<pre><code>2428677832187681074801010996569419611537028033553060588
8134740394131686305349870676240657821649938786653774568
44697837467174999512466010709212980674765975179401904173
50027463313770628365294401742988068945162971582587075902
61592865033437278850861444506927272718324998780980391309
71066003554034577228599139472327583180914625767704664425
90125804190638177118373078542499530049455096499902511032
100371114393629537113796511778272151802547292271926376588
</code></pre>

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

<p>Okay, so let's use small numbers to illustrate that clearly.</p>

<p>Suppose you pick a random number from 1 to 100, inclusively.</p>

<p>How many 1 digit numbers are there? 9, from 1 to 9. For 2 digits it's from 10 to 99, 90 numbers. For 3 digits it's just 1, 100. Since it's a random pick, the probability of picking one of those 100 (9 + 90 + 9) numbers is equal, and it should be intuitively clear it's 1/100. But since there are 90 2-digit numbers, the probability of picking a 2-digit number is 90/100, or 9/10. For 1-digit numbers it's 9/100, and for the only 3-digit one it's 1/100.</p>

<p>I hope that answers the question.</p>

python random