So what i want to do it's to assign an argument(x p.e) to the probabilty of returning it. Example : if x is 0.22, i will have a 22% probabilty of return True; if x is below 0 or higher than 1, then assign x = 0.5 p.e idk what to write in return part...so i tried this solution but without sucess
def gen_true(x):
for x in range(0,1):
x = float(x)
if x > 100 or x < 0:
p = 0.5
elif 1 < x < 100:
x = x / 100
return random.randrange(100) < x
gen_true(0.70)
Aucun commentaire:
Enregistrer un commentaire