From a19a216bc60160c162e616145ef091dd18ce4e61 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Tue, 16 Feb 2021 14:40:46 -0600 Subject: Python 0.9.1 as posted in alt.sources --- lib/rand.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/rand.py (limited to 'lib/rand.py') diff --git a/lib/rand.py b/lib/rand.py new file mode 100644 index 0000000..0ca1a53 --- /dev/null +++ b/lib/rand.py @@ -0,0 +1,12 @@ +# Module 'rand' + +import whrandom + +def srand(seed): + whrandom.seed(seed%256, seed/256%256, seed/65536%256) + +def rand(): + return int(whrandom.random() * 32768.0) % 32768 + +def choice(seq): + return seq[rand() % len(seq)] -- cgit v1.2.3