mrandom
This package provides a random number generator. It is based on the Mersenne Twister algorithm. It includes both 32 and 64 bit versions of the algorithm. The generator has large period of 2^19937-1
Features
- Can generate random numbers
- Can return a choice from a list
- Can shuffle a list
- Can flip a coin
- Can roll a die
- Can shuffle a deck
Installing the package
pip install mrandom
Importing the module
>>> import mrandom
# 1 = 32 bit, 2 = 64 bit algorithm
>>> random = mrandom.RandomGenerator(s)
Examples
Return a random number between 0 and 1
>>> print(random.rand())
0.9888888888888889
Return a random number between a and b (inclusive)
>>> print(random.randint(a, b))
1
Return a random number between a and b (exclusive)
>>> print(random.randrange(a, b))
12
Return k random numbers between a and b (inclusive)
>>> print(random.sample(a, b, k))
[1, 2, 3, 4, 5]
Return a random number from a list l
>>> print(random.choice(l))
21
Return shuffled list l
>>> print(random.shuffle(l))
[1, 3, 5, 4, 2]
Return sample of flipping k coins n times
>>> print(random.flip_coin(n, k))
[1, 0, 0, 1, 0]
Return sample of rolling k dices n times
>>> print(random.roll_dice(n, k))
[[1, 4], [1, 1]]
Return sample of picking a card from a deck of 52 cards n times
>>> print(random.shuffle_deck(n))
["Ace of Spades", "Ace of Hearts", "Ace of Clubs", "Ace of Diamonds", "Ace of Clubs"]
Classes
mrandom.RandomGenerator - Random number generator
Methods:
| Methods | Description |
|---|---|
rand() |
Return a random number between 0 and 1 |
randint(a, b) |
Return a random number between a and b (inclusive) |
randrange(a, b) |
Return a random number between a and b (exclusive) |
sample(a, b, k) |
Return k random numbers between a and b (inclusive) |
choice(l) |
Return a random number from a list l |
shuffle(l) |
Return shuffled list l |
flip_coin(n, k) |
Return sample of flipping k coins n times |
roll_dice(n, k) |
Return sample of rolling k dices n times |
shuffle_deck(n) |
Return sample of picking a card from a deck of 52 cards n times |
Metadata
Release files for py-mrandom 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-mrandom-0.1.tar.gz | 5.7 kB | Without provenance | Details for py-mrandom-0.1.tar.gz |
Release files / py-mrandom-0.1.tar.gz
| Download URL | py-mrandom-0.1.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a05fae4bdbc50986b342c509f37ca39d058644bffd1cad7345c0de5dd32a73e2
|
|
BLAKE2b-256 checksum How to use checksums |
70a01b713c5add2f9c4f8b66448dc23710a2ee1f1268045e57225e6f9dbcbccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for py-mrandom 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.