Skip to main content

random_number_list

Creates a list of randomly drawn numbers from a larger list. Can be used to pick lottery numbers.

Installation

Run the following to install:

pip install random-number-list

Usage

from random_number_list import RandomNumberList

new_list = RandomNumberList.return_list(number, pick, put_back)

print(new_list)

print(RandomNumberList.verify_number(number))
print(RandomNumberList.verify_pick(number, pick))

Example

new_list = RandomNumberList.return_list(15, 5, False)

print(new_list)

returns:

[12, 9, 1, 8, 4]

Basis of operation

When the object is called, you pass the following variables:

number:

The number of items in the pool to be picked from.
example:
number = 5 will create a pool [1, 2, 3, 4, 5]

pick:

The number of items to be randomly drawn from the pool.
example:
pick = 2 will return a list of the randomly drawn items, say [4, 2]

put_back:

Whether an item is put back into the pool prior to the next draw.
Input as a boolean True or False, with a default of False.

error_text:

Optional Boolean variable with a default of False.
If True is passed, a simple explanatory error message is output.

Note:

digits after a decimal point are ignored.
5, 5.0, 5.2 & 5.9 all equate to 5

Methods

RandomNumberList.return_list(number, pick, put_back, error_text)

Used to create the list of randomly drawn numbers:

RandomNumberList.verify_number(number, error_text)

Validates that a number greater than or equal to one has been passed.

RandomNumberList.verify_pick(number, pick, error_text)

Validates that:
number: is greater than or equal to one
pick: is greater than or equal to one AND less than or equal to number

Install Requires

This package uses the following standard library packages:

  1. random

In Closing

This package has been built as part of my learning Python so may contain coding that is not best practice. I am happy for more experienced Python users to feedback any areas that could be improved. Once I get to understand uploading packages to PyPI I will set up development dependencies.

Release files for random-number-list 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for random-number-list 0.0.1
File Size Uploaded
random_number_list-0.0.1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for random-number-list 0.0.1
File Interpreter ABI Platform
random_number_list-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / random_number_list-0.0.1.tar.gz

Download URL random_number_list-0.0.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ebb39f03b506cbfe5ef1db6045b820e5cdb5510ad5fb2ae14c3a009996a91a2f
BLAKE2b-256 checksum
How to use checksums
73df0a00036c27f8d1cc3dd3db3b73847ade56cbdbb4b051d85ae3c3a8bad141
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release files / random_number_list-0.0.1-py3-none-any.whl

Download URL random_number_list-0.0.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bed636a6eff25a2a924cee0e79d6277a0582f298f9de39c2c583c3211057d0a9
BLAKE2b-256 checksum
How to use checksums
b99b279f312648a1f226f28aeacc2e0fe96ac26c30ae836b3cb9f82f00671309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page