So if the array I made to simulate picking a coloured ball from a bag looked like this:
A = ["Blue", "Green", "Yellow"]
then I could just use the
random.choice()
function to simulate picking one from the bag. But if I had a different amount of coloured balls in the bag (say 3 green, 5 blue and 10 yellow), how could I make the random choice from the array reflect the different probabilities of picking each colour?
Aucun commentaire:
Enregistrer un commentaire