import random

def galton5():
    L=[]
    for i in range(6):
        L.append(0)
    S=0
    for k in range(5):
        S=S+random.randint(0,1)
    L[S]=L[S]+1
    return L

def galton5_bis(n_billes):
    L = [0, 0, 0, 0, 0, 0]
    for i in range(n_billes):
        S = 0
        for k in range(5):
            S = S + random.randint(0, 1)
        L[S] = L[S] + 1
    return L
    
def galton5_frequence(n_billes):
    L=galton5_bis(n_billes)
    for i in range(len(L)):
        L[i] = L[i] / n_billes
    return L

print(galton5())
print(galton5_bis(100))
print(galton5_frequence(100000))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: