![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=Python&logoColor=white)
![PyPI](https://img.shields.io/badge/PyPI-3775A9?style=for-the-badge&logo=PyPI&logoColor=white)
![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)
The English version of the README.md file was created by a translator. Therefore, the translation may not be accurate. If you can use Korean, we recommend that you view the Korean document.
[한국어 문서 바로가기(korean)](https://github.com/yhg4908/ranpick.py/blob/main/README_KR.md)
# Ranpick
[![PyPI version](https://badge.fury.io/py/ranpick.svg)](https://badge.fury.io/py/ranpick)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ranpick)
![PyPI - Downloads](https://img.shields.io/pypi/dm/ranpick)
Ranpick complements the shortcomings of the existing PRNG method and generates random numbers with nanoseconds and hash-based systems.
---
## Installation
1. Use 'pip' to install the ranpick:
```bash
pip install ranpick
```
2. Add the import statement below to the code (.py) to import the ranpick:
```python
import ranpick
```
## Modules and Use Guides
As of `2024.12.7 (KST)`, the modules currently available are as follows.
- rannumber: `Produces a random number in the form of a number`
- ranrandom: `Select a random value from the list.` (2.1.0~)
### number - Generating a numeric random number
`Number` generates a random number in the form of a normal number.
You can generate numbers up to 100000000.
#### The basics
The number module can be used in the following ways.
```python
random_number = ranpick.rannumber() # random_number variable, store the random number (~100000000) that is selected as the random number module.
print(random_number) # print_number The value of the variable random_number.
print(ranpick.rannumber()) #rampicknumber Outputs the value of the random number drawn by the module.
```
This is the basic method of using the number module. You can generate random numbers with `ranpick.number()`.
#### Limiting the Number of Random Numbers
You can also limit the number of random numbers. The example code below limits random numbers to between 5 and 10.
```python
limit_number = ranpick.rannumber(5, 10)
print(limit_number)
print(ranpick.rannumber(5, 10))
```
`ranpick.number(5, 10)` is a code that limits the number of random numbers to between 5 and 10. You can complete it by adding `starting numbers, arriving numbers` in `()`.
Calculations such as ' `2+3,10/2` can also be used to limit the number of random numbers and can be used in all the contents to be described later.
#### Set decimal place
By default, a generated random number can only be generated with integers. However, if you refer to the example below, you can output a small number of outputs.
```python
decimal_number = ranpick.rannumber(0, 1, "d3")
print(decimal_number)
print(ranpick.number(0,1, "d3"))
```
This example code is a code that outputs numbers between 0 and 1 up to three decimal places. `"d3"` means that it outputs up to three decimal places.
If `"d4"` is used, it can be output up to four decimal places.
It can be up to 10 digits.
#### Application
The codes below are created by applying this module, other libraries, and modules. In addition to the examples used here, a variety of other libraries and applications are possible.
##### DataTime Library Application
Below is the code applied using the datetime library.
```python
import ranpick
from datetime import datetime
date_number = int(datetime.now().strftime("%Y%m%d%H%M%S"))
print(ranpick.rannumber(date_number, date_number × 10))
```
This code was made to output random numbers by leveraging the time output from the datetime library.
##### Ramdom Module Application
Below is the code applied using the random module.
```python
import ranpick
import random
random_number = random.randint(1,10)
print(random_number, 100)
```
This code generates another random number by using the random number output from the random module. It can be applied to produce almost unpredictable random numbers.
However, using this type of code is not recommended because it requires a lot of resources on your computer.
### ranrandom - Random Value Selection
`ranrandom` selects and outputs a random value from a list.
#### Basic Usage
You can use the `ranrandom` module as shown below:
```python
random = ranpick.ranrandom("left", "right", "center", "miss")
print(random)
print(ranpick.ranrandom("left", "right", "center", "miss"))
```
You can use `ranpick.ranrandom()`. Inside the parentheses, you can input items in a format such as `("win", "miss")`.
One of the items listed here will be randomly selected.
At least two items must be provided.
#### Setting Probabilities
You can set the probabilities for each item. Please refer to the example code below:
```python
random = ranpick.ranrandom(("left", 33), ("right", 33), ("center", 33), ("miss", 1))
print(random)
print(("left", 33), ("right", 33), ("center", 33), ("miss", 1))
```
You can add another pair of parentheses `()` inside the main `()`.
Within this added `()`, you can specify items in the format `("item_name", probability[%])`.
The total sum of all probabilities must equal 100, otherwise an error will occur.
```python
print("left", ("right", 50), "center", "miss")
```
If some probabilities are omitted as shown above, the remaining probabilities will be automatically redistributed among the unspecified items.
#### Multiple selection (planned for 2.2.0)
Of course, multiple selection is possible. Please follow the example below.
```python
random = ranrandom("a", "b", "c", "d", DS=2)
print(random)
```
This code selects 2 out of a, b, c, d and prints them. DS is in charge of how many to select and print.
If the value of DS is 2, 2 are selected from the list. If `DS=3`, 3 are selected and printed.
```r
a, d
```
It is printed like this.
##### Print in list form
Duplicated values can also be printed in list form.
```python
random = ranrandom("a", "b", "c", "d", DS=3, as_list=True)
print(random)
```
If you want to print in list format, use `as_list`. If you set the value of as_list to True and run it, it will print as follows.
```r
['b', 'c', 'a']
```
## Bug report
Please report bugs on the site below (github).
<https://github.com/yhg4908/ranpick.py/issues>
Raw data
{
"_id": null,
"home_page": "https://github.com/yhg4908/ranpick.py",
"name": "ranpick",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "random number generation entropy ranpick list Probability",
"author": "rainy58",
"author_email": "yhg4908@kakao.com",
"download_url": "https://files.pythonhosted.org/packages/e7/1e/fab9a00a690c1f77f404f925ee12c420644482ed99d167c72177c2292c0f/ranpick-2.2.0.tar.gz",
"platform": null,
"description": "![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=Python&logoColor=white)\n![PyPI](https://img.shields.io/badge/PyPI-3775A9?style=for-the-badge&logo=PyPI&logoColor=white)\n![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)\n\n\nThe English version of the README.md file was created by a translator. Therefore, the translation may not be accurate. If you can use Korean, we recommend that you view the Korean document.\n[\ud55c\uad6d\uc5b4 \ubb38\uc11c \ubc14\ub85c\uac00\uae30(korean)](https://github.com/yhg4908/ranpick.py/blob/main/README_KR.md)\n\n# Ranpick\n[![PyPI version](https://badge.fury.io/py/ranpick.svg)](https://badge.fury.io/py/ranpick)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ranpick)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/ranpick)\n\n\n\nRanpick complements the shortcomings of the existing PRNG method and generates random numbers with nanoseconds and hash-based systems.\n\n\n---\n\n\n\n## Installation\n\n\n\n1. Use 'pip' to install the ranpick:\n\n ```bash\n pip install ranpick\n ```\n2. Add the import statement below to the code (.py) to import the ranpick:\n\n ```python\n import ranpick\n ```\n\n\n\n## Modules and Use Guides\n\n\nAs of `2024.12.7 (KST)`, the modules currently available are as follows.\n\n- rannumber: `Produces a random number in the form of a number`\n- ranrandom: `Select a random value from the list.` (2.1.0~)\n\n\n\n### number - Generating a numeric random number\n\n\n`Number` generates a random number in the form of a normal number.\n\nYou can generate numbers up to 100000000.\n\n\n\n#### The basics\n\n\n\nThe number module can be used in the following ways.\n```python\nrandom_number = ranpick.rannumber() # random_number variable, store the random number (~100000000) that is selected as the random number module.\n\nprint(random_number) # print_number The value of the variable random_number.\nprint(ranpick.rannumber()) #rampicknumber Outputs the value of the random number drawn by the module.\n```\nThis is the basic method of using the number module. You can generate random numbers with `ranpick.number()`.\n\n\n#### Limiting the Number of Random Numbers\n\n\n\nYou can also limit the number of random numbers. The example code below limits random numbers to between 5 and 10.\n```python\nlimit_number = ranpick.rannumber(5, 10)\n\nprint(limit_number)\nprint(ranpick.rannumber(5, 10))\n```\n`ranpick.number(5, 10)` is a code that limits the number of random numbers to between 5 and 10. You can complete it by adding `starting numbers, arriving numbers` in `()`.\n\nCalculations such as ' `2+3,10/2` can also be used to limit the number of random numbers and can be used in all the contents to be described later.\n\n\n#### Set decimal place\n\n\n\nBy default, a generated random number can only be generated with integers. However, if you refer to the example below, you can output a small number of outputs.\n```python\ndecimal_number = ranpick.rannumber(0, 1, \"d3\")\n\nprint(decimal_number)\nprint(ranpick.number(0,1, \"d3\"))\n```\nThis example code is a code that outputs numbers between 0 and 1 up to three decimal places. `\"d3\"` means that it outputs up to three decimal places.\n\nIf `\"d4\"` is used, it can be output up to four decimal places.\n\nIt can be up to 10 digits.\n\n\n#### Application\n\n\n\nThe codes below are created by applying this module, other libraries, and modules. In addition to the examples used here, a variety of other libraries and applications are possible.\n\n##### DataTime Library Application\nBelow is the code applied using the datetime library.\n```python\nimport ranpick\nfrom datetime import datetime\n\ndate_number = int(datetime.now().strftime(\"%Y%m%d%H%M%S\"))\n\nprint(ranpick.rannumber(date_number, date_number \u00d7 10))\n```\nThis code was made to output random numbers by leveraging the time output from the datetime library.\n\n##### Ramdom Module Application\nBelow is the code applied using the random module.\n```python\nimport ranpick\nimport random\n\nrandom_number = random.randint(1,10)\n\nprint(random_number, 100)\n```\nThis code generates another random number by using the random number output from the random module. It can be applied to produce almost unpredictable random numbers.\n\nHowever, using this type of code is not recommended because it requires a lot of resources on your computer.\n\n### ranrandom - Random Value Selection\n`ranrandom` selects and outputs a random value from a list.\n\n#### Basic Usage\nYou can use the `ranrandom` module as shown below:\n```python\nrandom = ranpick.ranrandom(\"left\", \"right\", \"center\", \"miss\")\n\nprint(random)\nprint(ranpick.ranrandom(\"left\", \"right\", \"center\", \"miss\"))\n```\nYou can use `ranpick.ranrandom()`. Inside the parentheses, you can input items in a format such as `(\"win\", \"miss\")`.\nOne of the items listed here will be randomly selected.\nAt least two items must be provided.\n\n#### Setting Probabilities\nYou can set the probabilities for each item. Please refer to the example code below:\n```python\nrandom = ranpick.ranrandom((\"left\", 33), (\"right\", 33), (\"center\", 33), (\"miss\", 1))\n\nprint(random)\nprint((\"left\", 33), (\"right\", 33), (\"center\", 33), (\"miss\", 1))\n```\nYou can add another pair of parentheses `()` inside the main `()`.\nWithin this added `()`, you can specify items in the format `(\"item_name\", probability[%])`.\nThe total sum of all probabilities must equal 100, otherwise an error will occur.\n```python\nprint(\"left\", (\"right\", 50), \"center\", \"miss\")\n```\nIf some probabilities are omitted as shown above, the remaining probabilities will be automatically redistributed among the unspecified items.\n\n#### Multiple selection (planned for 2.2.0)\nOf course, multiple selection is possible. Please follow the example below.\n```python\nrandom = ranrandom(\"a\", \"b\", \"c\", \"d\", DS=2)\n\nprint(random)\n```\nThis code selects 2 out of a, b, c, d and prints them. DS is in charge of how many to select and print.\n\nIf the value of DS is 2, 2 are selected from the list. If `DS=3`, 3 are selected and printed.\n```r\na, d\n```\nIt is printed like this.\n\n##### Print in list form\nDuplicated values \u200b\u200bcan also be printed in list form. \n```python\nrandom = ranrandom(\"a\", \"b\", \"c\", \"d\", DS=3, as_list=True)\n\nprint(random)\n```\nIf you want to print in list format, use `as_list`. If you set the value of as_list to True and run it, it will print as follows.\n```r\n['b', 'c', 'a']\n```\n\n## Bug report\n\n\nPlease report bugs on the site below (github).\n\n<https://github.com/yhg4908/ranpick.py/issues>\n",
"bugtrack_url": null,
"license": null,
"summary": "A high-entropy random number generation library",
"version": "2.2.0",
"project_urls": {
"Homepage": "https://github.com/yhg4908/ranpick.py"
},
"split_keywords": [
"random",
"number",
"generation",
"entropy",
"ranpick",
"list",
"probability"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9db95751c5392b1028bff65b5a69fd4c8b223a42ff7c9229199a2e192eb2791c",
"md5": "7c00990beb3e1106e8cccfcec1312423",
"sha256": "ceb13ec1f90590cbc01b48ff2ae61099d0c37e6a71a4e0754d97ee5c3b556dec"
},
"downloads": -1,
"filename": "ranpick-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c00990beb3e1106e8cccfcec1312423",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6998,
"upload_time": "2024-12-22T02:18:32",
"upload_time_iso_8601": "2024-12-22T02:18:32.712433Z",
"url": "https://files.pythonhosted.org/packages/9d/b9/5751c5392b1028bff65b5a69fd4c8b223a42ff7c9229199a2e192eb2791c/ranpick-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e71efab9a00a690c1f77f404f925ee12c420644482ed99d167c72177c2292c0f",
"md5": "d0b6121c7527ccb656e3f6456d6c33f7",
"sha256": "f0ec3eb3f0bba90f9c22af32643047b3c205958d88e7055aa9f69884f7016ea4"
},
"downloads": -1,
"filename": "ranpick-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "d0b6121c7527ccb656e3f6456d6c33f7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6926,
"upload_time": "2024-12-22T02:18:34",
"upload_time_iso_8601": "2024-12-22T02:18:34.932052Z",
"url": "https://files.pythonhosted.org/packages/e7/1e/fab9a00a690c1f77f404f925ee12c420644482ed99d167c72177c2292c0f/ranpick-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 02:18:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yhg4908",
"github_project": "ranpick.py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ranpick"
}