True random numbers (provided by random.org) in Python
Project description
verarandom
True random numbers (provided by random.org) in Python
Usage
This module provides a random.Random subclass, so it implements all random functions (excluding Bookkeeping functions) with true randomness. It requires an internet connection to work and will raise a ConnectionError if the server doesn't respond, a requests.HTTPError or a subclass of verarandom.VeraRandomError if there is a problem with the request's parameters.
NOTE: this class assumes it's the only one talking to random.org when calculating its quota.
>>> from verarandom import VeraRandom
>>> r = VeraRandom()
>>> r.remaining_quota
1000000
>>> r.randint(1, 10, n=5)
[3, 4, 10, 3, 7]
>>> r.remaining_quota # bits were deducted from quota
999986
>>> r.randint(3, 5, n=1)
[5]
>>> r.randint(-10, 3) # If no n is passed it returns a number, not a list (like the parent method)
-2
>>> r.random()
0.040120765652295
>>> r.choice(['rock', 'paper', 'scissors'])
'scissors'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
verarandom-1.0.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for verarandom-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87c7709383c42262fcbfdb276c8608555c82c93c59aad9c87f04e7bdf0fc7f47 |
|
MD5 | 355f236deee6a78a520cf4397151e5e8 |
|
BLAKE2b-256 | a47f80f14eefd756f7b7e4e46b1a5606ca727c0ba3bc1313f053c195348256b2 |