+ 2
How to create random with unequal possibility?
for example random from a to z
5 Réponses
+ 13
Maybe you could have a string like "aaaaaaaaaaaabbbbc..."
a has 60%, b has 20% and c has 5%...
+ 3
from random import randint
x = randint(1, 100)
letter = 'z'
if x < 61:
letter = 'a'
elif 60 < x < 81:
letter = 'b'
elif 80 < x < 86:
letter = 'c'
....... etc
+ 2
import string
import random
# or string.ascii_letters
random.choice(string.letters)
+ 1
i mean for example the possibility of choosing be: a=60% , b=20% , c=5% , ...(unequal possibility)
0
for example we have three char (a,b,c)
, i want to select randomly one of them with contigency a=60%, b=10% , c=30%.