-1

example:

import random
random.seed(10)
n1=random.randint(1,5)
n2=random.randint(1,5)
print(n1,n2)  # => 5,1

I am not good at English, so I used a translator. Please understand if it's awkward.

If there is the same number in parentheses behind the 'seed' in the same expression, does the value always come out the same? I wonder what the numbers in parentheses do. Run a no number expression multiple times, the value change all the time.

똑같은 식에서 seed 뒤의 괄호 안에 같은 숫자가 들어가면 값도 무조건 똑같이 나오나요? 괄호 안에 들어가는 숫자가 무슨 역할을 하는지 궁금합니다. 숫자를 넣지 않은 식에서는 여러번 실행하면 값이 계속 바뀝니다.

pjs
  • 18,696
  • 4
  • 27
  • 56
2teu Han
  • 3
  • 1
  • They don't seem to have a Korean translation of this part of the Python function documentation, but that is where you can read what all these parameters do: https://docs.python.org/ko/3/library/random.html – Thilo Oct 13 '19 at 08:08
  • Possible duplicate of [random.seed(): What does it do?](https://stackoverflow.com/questions/22639587/random-seed-what-does-it-do) – Thilo Oct 13 '19 at 08:09

1 Answers1

0

Given two random instances within the same seed, the nth call to randint on the first instance will yield the same number as the nth call on the second instance.

That does not mean that the random value returned across multiple calls for the same instance will be the same.

You will see the same ordered series of values, meaning if you were to run your python program at some different time, you would see the output 5,1 once again.

Mario Ishac
  • 5,060
  • 3
  • 21
  • 52