0

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!

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
claudioz
  • 1,121
  • 4
  • 14
  • 25
  • 1
    If the number is determined by the input, it isn't very random. I would suggest looking into hashes and how they take an input and deterministically turn it into a number. – TheCrzyMan Apr 12 '19 at 13:27
  • Can I assume that when you say "this value must always be the same until the input x remains the same", you mean "this value must always be the same as long as the input x remains the same"? – Kevin Apr 12 '19 at 13:27
  • @Kevin Yes exactly – claudioz Apr 12 '19 at 13:30

0 Answers0