blob: c299d0a9a95d6a10a332da9613d753f3683c3781 [file] [log] [blame]
Guido van Rossumc6360141990-10-13 19:23:40 +00001# Module 'rand'
Guido van Rossum668317d1991-08-16 13:28:11 +00002# Don't use unless you want compatibility with C's rand()!
Guido van Rossumc6360141990-10-13 19:23:40 +00003
4import whrandom
5
6def srand(seed):
7 whrandom.seed(seed%256, seed/256%256, seed/65536%256)
8
9def rand():
10 return int(whrandom.random() * 32768.0) % 32768
11
12def choice(seq):
13 return seq[rand() % len(seq)]