dimanche 14 octobre 2018

python rolling 3 dice

The task is: throw three dice and sum their results. Run that function 10 thousand times and compute the average and the standard deviation of the results.

My question is: I wrote the code and get 10000 sum as 'b'. Now, I need to sum them and take the average. I do not know how to proceed.

import random

rolls = 10000; #rolling 10000 times
for i in range(0, rolls):
    die1 = random.randint(1,6)
    die2 = random.randint(1,6)
    die3= random.randint(1,6)
    a=[die1, die2 ,die3]
    b=sum(a)
    print(b)




Aucun commentaire:

Enregistrer un commentaire