Write a function that generates one of 3 numbers according to given probabilities |  ; This function generates ' x ' with probability px / 100 , ' y ' with probability py / 100 and ' z ' with probability pz / 100 : Assumption : px + py + pz = 100 where px , py and pz lie between 0 to 100 ; Generate a number from 1 to 100 ; r is smaller than px with probability px / 100 ; r is greater than px and smaller than or equal to px + py with probability py / 100 ; r is greater than px + py and smaller than or equal to 100 with probability pz / 100
import random NEW_LINE def random ( x , y , z , px , py , pz ) : NEW_LINE INDENT r = random . randint ( 1 , 100 ) NEW_LINE if ( r <= px ) : NEW_LINE INDENT return x NEW_LINE DEDENT if ( r <= ( px + py ) ) : NEW_LINE INDENT return y NEW_LINE DEDENT else : NEW_LINE INDENT return z NEW_LINE DEDENT DEDENT