Basic Api
Module for interacting with the Random.org Basic API to generate random data.
- class py_random_dot_org.basic_api.BasicApi(api_key: str, version: int = 4, version_str: str = '4.0', warn_below_quota_requests: int = 0, warn_below_quota_bits: int = 0)[source]
Bases:
objectBasic Api Wrapper for the Random.org API.
- generate_blobs(num: int, size: int, id=1) list[str][source]
Generate random blobs of data.
- Args:
num (int): The number of blobs to generate. size (int): The size of each blob in bytes. id (int): The identifier for the request. Defaults to 1.
- Returns:
The generated blobs of data.
- generate_decimal_fractions(num: int, decimal_places: int, replacement=True, id: int = 1) list[float][source]
Generate decimal fractions.
- Args:
num (int): The number of decimal fractions to generate. decimal_places (int): The number of decimal places for each fraction. replacement (bool): Whether to allow replacement of values.
Defaults to True.
id (int): The identifier for the request. Defaults to 1.
- Returns:
The generated decimal fractions.
- generate_gaussians(num: int, mean: float, standard_deviation: float, significant_digits: int, id: int = 1) list[float][source]
Generate Gaussian-distributed numbers.
- Args:
num (int): The number of Gaussian numbers to generate. mean (float): The mean of the Gaussian distribution. standard_deviation (float): The standard deviation of the
Gaussian distribution.
significant_digits (int): The number of significant digits for the output. id (int): The identifier for the request. Defaults to 1.
- Returns:
The generated Gaussian-distributed numbers.
- generate_integer_sequences(num: int, length: list[int], minimum: list[int], maximum: list[int], replacement: list[bool] = None, base: list[int] = 10, id: int = 1) list[list[int]][source]
Generate integer sequences.
- Args:
num (int): The number of sequences to generate. length (list[int]): The lengths of the sequences. minimum (list[int]): The minimum values for each sequence. maximum (list[int]): The maximum values for each sequence. replacement (list[bool]): Whether to allow replacement of values in
each sequence. Defaults to None.
- base (list[int]): The base for encoding the integers in each sequence.
Defaults to 10.
id (int): The identifier for the request. Defaults to 1.
- Returns:
The generated sequences.
- generate_integers(num: int, minimum: int, maximum: int, replacement: bool = True, base: int = 10, pregenerateRandomiztion: dict | None = None, id: int = 1) list[int | str][source]
Generate true random integers within a user-defined range.
- Args:
num (int): The number of integers to generate. minimum (int): The minimum value of the integers. maximum (int): The maximum value of the integers. replacement (bool): Whether to allow replacement of values.
Defaults to True.
base (int): The base for encoding the integers. Defaults to 10. pregenerateRandomiztion (dict | None): Optional parameter for
pre-generation randomization. Defaults to None.
id (int): The identifier for the request. Defaults to 1.
- Returns:
list[int | str]: The generated integers.
- generate_strings(num: int, length: int, characters: str, replacement=True, id=1) list[str][source]
Generate random strings.
- Args:
num (int): The number of strings to generate. length (int): The length of each string. characters (str): The characters to use for generating the strings. replacement (bool): Whether to allow replacement of characters.
Defaults to True.
id (int): The identifier for the request. Defaults to 1.
- Returns:
The generated strings.