Skip to main content

Python Library to draw with percentage

Project description

Draw with percentages

Python library for randomizing given elements with the appropriate percentage chance.

Example:

Sample library usage

Code:
from draw_with_percentage import draw_with_percentage

percentages = [
    ["option1", "10"],
    ["option2", "20"],
    ["option3", "30"],
    ["option4", "40"]
]

res = draw_with_percentage(percentages)
Response:
  1. Option 1 10% chance will be refunded.
  2. Option 2 20% chance will be refunded.
  3. Option 3 30% chance will be refunded.
  4. Option 4 40% chance will be refunded.

Request:

[
    ["name", "percent"],
    ["name", "percent"],
    ["name", "percent"],
    ["name", "percent"]
    // etc.
]
Remember:
  • In the first field we give the name of the element.
  • In the second field we give the percentage written as a string.
    • We write the percentage down to three places after the decimal point.
  • The sum of all percentages must be 100.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

draw with percentage-0.0.6.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

draw_with_percentage-0.0.6-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page