import random
lt = ['q1','q2', 'q3']
res=[]
for i in range(10000):
rnd=random.random()
if rnd<0.2:
res.append(lt[0])
elif rnd<0.5:
res.append(lt[1])
else:
res.append(lt[2])
print(res.count(lt[0]),res.count(lt[1]),res.count(lt[2]))
2018 3020 4962
random.choices(['q1', 'q2', 'q3'], weights=[0.2, 0.3, 0.5])
collections.Counter( random.choices(['q1', 'q2', 'q3'], weights=[0.2, 0.3, 0.5]))[0] for _ in range(100000))
>>> collections.Counter( random.choices(['q1', 'q2', 'q3'], weights=[0.2, 0.3, 0.5]) [0] for _ in range(100000))
Counter({'q3': 49981, 'q2': 30018, 'q1': 20001})