Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Blood Alcohol Content/Blood_Alcohol_Content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class BAC(object):
def __init__(self,weight, time, vol, amount, gender):
self.weight = weight
self.time = time
self.vol = vol
self.amount = amount
self.gender = gender
self.std = 0.0068
def standard_drink(self):
return round((self.std * self.vol) * self.amount, 2)
def promille_man(self):
return round((self.standard_drink() * 12) / ((self.weight*1.7) - (0.15*self.time)), 2)
def promille_woman(self):
return round((self.standard_drink() * 12) / ((self.weight*1.6) - (0.15*self.time)), 2)


def result(self):
if self.gender == 'woman':
print(f'\nAs a woman who have had {self.amount} cl. of {self.vol}% vol, {self.time} hour ago.')
print(f'You`ve had {self.standard_drink()} drinks,which gives you a {self.promille_woman()}% BAC\n')
elif self.gender == 'man':
print(f'\nAs a man who have had {self.amount} cl. of {self.vol}% vol, {self.time} hour ago.')
print(f'You`ve had {self.standard_drink()} drinks,which gives you a {self.promille_man()}% BAC\n')
else:
print("Fault.")

if __name__ == "__main__":
weight = int(input("Weight of the patient in kg: "))
time = int(input("Enter the time of drink (in hour only): "))
vol = float(input("Volume percent of alcohol in the drink:"))
amount = int(input("Enter the amount the you drank: "))
gender = str(input("You are man or woman: "))

BAC(weight,time,vol,amount,gender).result()
22 changes: 22 additions & 0 deletions Blood Alcohol Content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Blood Alcohol Content

Want to know how much amount of alcohol you drank? Well, the Blood alcohol content program will help you find out the alcohol intake.

## Installation

- Install Python to your system if it's not available.

**Now you are ready to run the code**

## Steps to run:

- Open the **Blood_Alcohol_Content.py** file i.e run it.
- To run it, you can open command prompt/shell/terminal in the containing folder and type the following command:
```
python Blood_Alcohol_Content.py
```
## Output:
```
As a woman who have had 50 cl. of 4.6% vol, 1 hour ago.
You've had 1.56 drinks,which gives you a 0.14% BAC
```