samedi 3 novembre 2018

How do I get the average of the output of a variable?

So, I have a variable that outputs either a 0 or 1. Now, I want to run it 10,000 times and get the average of it.

import random

def roll_dice():

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

    x = random.sample(available, 1)
    del available[x[0]]
    y = random.sample(available, 1)
    z = x[0] + y[0]

    if z == 7:
        count = 1
    else:
        count = 0

    print(z)
    print(count)
    return count

roll_dice() 

So basically, I want to know what what the chance is that my dice roll returns 7.




Aucun commentaire:

Enregistrer un commentaire