vendredi 12 avril 2019

Python: deterministic random function?

I'm developing a little script using Python 3.6. I have a question. If I have a range of number (for example a range of number between 1 and n) and I would like to create a function that, taken as input x some integer value (whatever it is), it returns a randomly chosen value between 1 and n, but this value must always be the same until the input x remains the same! I don't know how to do this (I think it's simple). If I create the function like this:

def random_determ(x):
   return random.randint(1, n)

obviously it doesn't work because the random choice doesn't depend in any way on x. Thanks for the help!




Aucun commentaire:

Enregistrer un commentaire