A Python package for random element selection from various data structures.
Project description
randomChoice.py
randomChoice.py is a Python module that provides functions for selecting random elements from various data structures such as lists, tuples, sets, and dictionaries.
Installation
Simply download randomChoice.py and place it in your project directory. It does not require any external dependencies beyond Python's standard library.
from randomChoice import random_value
Usage/Examples
from randomChoice import random_value
# Example usage
array = ["rays", "sun", "moon", "earth"]
tuple_obj = ("apple", "banana", "cherry")
set_obj = {"apple", "banana", "cherry"}
dict_obj = {1: "house", 5: "road", 8: "shop", 3: "store"}
print(random_element(array)) # Random element from array
print(random_element(tuple_obj)) # Random element from tuple
print(random_element(set_obj)) # Random element from set
print(random_element(dict_obj)) # Random value from dict
Function random_value
Parameters
obj(list or tuple or set or dict): The input list, tuple, set, or dictionary from which to select a random element.
Returns
- Returns a random element from the input list, tuple, or set.
- Returns a random key-value pair (tuple) from the input dictionary.
Raises
TypeError: If the input is not a list, tuple, set, or dictionary.
License
🚀 About Me
I'm a student full stack developer at Atlas School, Tulsa...
Authors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qodebreeder-0.1.tar.gz.
File metadata
- Download URL: qodebreeder-0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
718a2da6f5acd3fbcc1c379a6fdda626f4b65bc35e9ea1fe96e428ebef89c45a
|
|
| MD5 |
6386f0d685ef01301a5372f96caf05c0
|
|
| BLAKE2b-256 |
0675b846c03a96765c6a4ab8d29922293e1109f2107d01bd478dd2ce5bb1b432
|
File details
Details for the file qodebreeder-0.1-py3-none-any.whl.
File metadata
- Download URL: qodebreeder-0.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4780883093c275d4e3440878101b5a1bd04e5eea28fa1fd4c4678ef9eb7e7d32
|
|
| MD5 |
5946ecdf8b152aa2c4420a47412ea6d2
|
|
| BLAKE2b-256 |
dabfef51dfc325784472d58c40b6d4dc5d1098d2fb46271dd44a60de738272ea
|