boozelib¶
A Python module containing a couple of functions to calculate the blood alcohol content of people.
It’s at home at https://github.com/brutus/boozelib/
Install¶
You can install it from PyPi, it is known as boozelib
and has no
dependencies:
pip install --user boozelib
Functions¶
The two main functions are:
-
boozelib.
get_blood_alcohol_content
(*, age: int, weight: int, height: int, sex: bool, volume: int, percent: float) → float[source] Return the blood alcohol contents raise (per mill) for a person after a drink.
Given a drink containing volume (ml) of alcohol with the percent (vol/vol), for a person with age (years), weight (kg) and height (cm), using the formular for “female body types” if sex is true.
-
boozelib.
get_blood_alcohol_degradation
(*, age: int, weight: int, height: int, sex: bool, minutes: int = 1) → float[source] Return the alcohol degradation (per mill) for a person over minutes.
For a person with age (years), weight (kg) and height (cm), using the formular for “female body types” if sex is true, over the given minutes.
Examples¶
>>> from boozelib import get_blood_alcohol_content
>>> get_blood_alcohol_content(
... age=32, weight=96, height=186, sex=False, volume=500, percent=4.9
... )
0.28773587455687716
>>> get_blood_alcohol_content(
... age=32, weight=48, height=162, sex=True, volume=500, percent=4.9
... )
0.5480779730398769
>>> from boozelib import get_blood_alcohol_degradation
>>> get_blood_alcohol_degradation(
... age=32, weight=96, height=186, sex=False, minutes=60
... )
0.21139778538872606
>>> get_blood_alcohol_degradation(
... age=32, weight=48, height=162, sex=True, minutes=60
... )
0.20133476560648536
Thanks and Contributions¶
- Big hugs to Mathilda for hanging around and helping me figuring out all that math and biology stuff.
If you find any bugs, issues or anything, please use the issue tracker on GitHub.