In Python, there is already a ready-made function to choose the winner according to the weights:
>>> import random >>> random.choices(['Катя', 'Коля'], weights=[10, 20]) ['Коля'] # пример возможного вывода
You can check that the Kolya is selected in ~ 2/3 cases, and Katya in ~ 1/3 on average:
>>> from collections import Counter >>> Counter(random.choices(['Катя', 'Коля'], weights=[10, 20])[0] ... for _ in range(100000)) Counter({'Коля': 66715, 'Катя': 33285})
For the case of only two participants, it is easy to independently implement the choice:
>>> 'Катя' if random.random() < 1/3 else 'Коля' 'Коля'
Similar results:
>>> Counter('Катя' if random.random() < 1/3 else 'Коля' ... for _ in range(100000)) Counter({'Коля': 66617, 'Катя': 33383})
To make it harder for the winner to predict, you can use the secrets module:
>>> import secrets >>> 'Катя' if secrets.randbelow(30) < 10 else 'Коля' 'Коля'
randbelow() can return 30 possible values [0, 30) , while for 10 dropped out values [0, 10) Katya is selected (1/3 vs. 2/3 division).
In general, there may be differences in how many random bits are generated and by what algorithm in the examples given. In different situations, different choices may be more appropriate.