random.seed(n)
Means "reset the random number generator to some known position n
". This means that the future outputs of the generator can be known in advance. It is useful for testing with the same "random" data over and over again.
What this code does is reset the generator every 15 steps, so you get the same sequence of 15 "random" integers (and, hence, of strings from the list) each time. In Python 2.x, the first "random" integer after the reset is always 0
(when I tried just now in Python 3, after random.seed(1178741599)
I get random.randint(0, 3) == 1
).
Note that this code does not do what a conventional FizzBuzz program does, and depends heavily on the random
implementation. It works for me in 2.7.3 but does not work in 3.3.2 (see Why is seeding the random
number generator not stable between versions of Python?).