Python Percentage
Calculate percentages without worrying about ZeroDivision errors
Install
pip install python_percentage
Usage
python_percentage comes with different useful functions for different percentage calculations
Calculate percentage between 2 floats
from python_percentage import get_percentage
# I want to get the 20.0% of 200.0
result = get_percentage(20.0, 200.0)
# 200.0 * float(20.0) / float(100.0)
print(result) # 40.0
Calculate which percentage represents a float based on another float
from python_percentage import percentage_of
# I want to get which percentage is 1.0 of 2.0
result = percentage_of(1.0, 2.0)
# 100.0 * float(1.0) / float(2.0)
print(result) # 50.0
Increment percentage of a float
from python_percentage import increment
# I want to increment a 10.0% the float 20.0
result = increment(10.0, 20.0)
# 20.0 + get_percentage(10.0, 20.0)
print(result) # 22.0
Decrement percentage of a float
from python_percentage import decrement
# I want to decrement a 10.0% the float 20.0
result = decrement(10.0, 20.0)
# 20.0 - get_percentage(10.0, 20.0)
print(result) # 18.0
Metadata
Release files for python-percentage 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_percentage-1.0.0.tar.gz | 3.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_percentage-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / python_percentage-1.0.0.tar.gz
| Download URL | python_percentage-1.0.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7dbf38bbe3786d41c484c8ed0471c0ca07850cc7558b1601d4f09be672f9c789
|
|
BLAKE2b-256 checksum How to use checksums |
78d07d064bec1ba30de95919688d88b4aa0ca668a8a6bc2a3a67b222cf63fb0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / python_percentage-1.0.0-py3-none-any.whl
| Download URL | python_percentage-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c265cbf0613ca48a379cdc2d4e3bfe569fcb0a571ab19d14f2ec8bad7954ac19
|
|
BLAKE2b-256 checksum How to use checksums |
f8ad8eb6e20e63d65876889889b346c19686eb70ba7b9f15f00b9d0c1658f5bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|