
Good time of day, habravchane. Despite the deep title of the post, its essence consists in describing the struggle with its own stupidity in solving the problems already studied. Recently, often pondered the topic of "randomness." What sets this same chance? In view of the fact that I like to reach everything myself, I did not get into search engines, but I got into Python.
First, the following algorithm came to mind:
1) Get a certain number of random numbers.
2) Find out how many in each random number of numbers "0", "1", "2", etc.
3) Calculate the sum of these numbers.
4) For clarity, build a diagram.
As a result, I was extremely surprised by my stupidity:

Why does the number of zeros so markedly exceed the number of all other digits? The answer was simple, but about him a little later.
I decided to increase the number of random numbers, suspecting in advance that the number would level off.
However, the picture that I saw was frightening:


The question after this immediately arose to the code in which the “random” number is generated as:
while ii<kol: a = random.random() z = str(a) L = len(z) i = 0 while i <L: if z[i]=="0": s0 +=1 elif z[i]=="1": s1 +=1 elif z[i]=="2": s2 +=1 elif z[i]=="3": s3 +=1 elif z[i]=="4": s4 +=1 elif z[i]=="5": s5 +=1 elif z[i]=="6": s6 +=1 elif z[i]=="7": s7 +=1 elif z[i]=="8": s8 +=1 elif z[i]=="9": s9 +=1 i+=1 ii +=1
I think you already guessed what was my first mistake? And it was in random.random (), which returns a random number from 0 to 1 with a certain number of decimal places.
This was not the end. Correcting the error:
... while ii<kol: a = random.random() z = str(a) l = len(z) i = 2 while i <L: if z[i]=="0": s0 +=1 elif z[i]=="1": ...
Got the following picture of "random":

This situation did not change with the increase in the number of numbers. However, here the answer was not at all in theory, but again in implementation. Guess?
The fact is that Python rounds the number obtained using random.random (). It is easy enough to understand that when rounding, “rounding to 0” is much less likely than “rounding off to any other number”. Since in order to “round up to 0,” it is necessary that the penultimate digit of a random number is 9. And this chance is 1 to 10.
“Healing” code:
while ii<kol: a = random.random() z = str(a) l = len(z) i = 2 while i <L-1: if z[i]=="0": s0 +=1 elif z[i]=="1":

Justice Randomness triumphed. Stupidity was destroyed. Be careful, dear habravchane. Thanks to everyone who read this post to the end.