vendredi 24 mars 2023

Why are the sums of randomly rolled dice in Python always 7? [closed]

import random

dice=[1,2,3,4,5,6]

possibilities=[]

def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

for i in range(1000):
    b=random.choice(dice) 
    c=random.choice(dice)
    possibilities.append(b+c)

print(most_frequent(possibilities))

I rolled random dice 1000 times. I listed the sum of the two dice. and it was the 7th most popping up almost every time. Anyone know why? very rarely 6 and 8 came out. because they are close to 7.




Aucun commentaire:

Enregistrer un commentaire