dimanche 24 décembre 2017

make cointoss 10times auto in python

now I'm trying to make auto coin toss and draw cumulative graph

i copy and understand here

import random
rest = []
toss = [random.randint(0,1) for t in range(10)]
    for i in toss:
        if i == 0:
            rest.append('0')
        else:
            rest.append('1')
print rest

i got list like [1,0,0,0,1,1,0,0,0,1]

so now i have to make list like this for 10 (10 times repeat coin toss) And how many '0' is appended into list so i wanna return result [3,7,5,6,3,3,4,5,8,9] this list mean each list got how many '0'is appended

Help please and thank you




Aucun commentaire:

Enregistrer un commentaire