How to choose one value with a certain probability?
📁 python, пример
Example. Katya scored 10 points, and Kolya scored 20 points. This means that in one case out of three Katya will win, and in two cases out of three Kolya will win.
It is necessary to randomly select the lottery winner, taking into account their probabilities of winning.
What formula is used to calculate this (a universal formula for any number of lottery participants is needed)?
P.S. The language is Python.
To get stdout into a variable in the subprocess module, there is the check_output function
import subprocessprint (""Start program"")def startProgram(cmd): output = subprocess.check_output(cmd, shell=True) retu outputif __name__ == '__main__': cmd = r'ssh root@10.6.13.11 ""/usr/bin/python3.2 -u /home/pi/priem2.py""' print(startProgram(cmd)) Log in to leave an answer