|
| 1 | +class BAC(object): |
| 2 | + def __init__(self,weight, time, vol, amount, gender): |
| 3 | + self.weight = weight |
| 4 | + self.time = time |
| 5 | + self.vol = vol |
| 6 | + self.amount = amount |
| 7 | + self.gender = gender |
| 8 | + self.std = 0.0068 |
| 9 | + def standard_drink(self): |
| 10 | + return round((self.std * self.vol) * self.amount, 2) |
| 11 | + def promille_man(self): |
| 12 | + return round((self.standard_drink() * 12) / ((self.weight*1.7) - (0.15*self.time)), 2) |
| 13 | + def promille_woman(self): |
| 14 | + return round((self.standard_drink() * 12) / ((self.weight*1.6) - (0.15*self.time)), 2) |
| 15 | + |
| 16 | + |
| 17 | + def result(self): |
| 18 | + if self.gender == 'woman': |
| 19 | + print(f'\nAs a woman who have had {self.amount} cl. of {self.vol}% vol, {self.time} hour ago.') |
| 20 | + print(f'You`ve had {self.standard_drink()} drinks,which gives you a {self.promille_woman()}% BAC\n') |
| 21 | + elif self.gender == 'man': |
| 22 | + print(f'\nAs a man who have had {self.amount} cl. of {self.vol}% vol, {self.time} hour ago.') |
| 23 | + print(f'You`ve had {self.standard_drink()} drinks,which gives you a {self.promille_man()}% BAC\n') |
| 24 | + else: |
| 25 | + print("Fault.") |
| 26 | + |
| 27 | +if __name__ == "__main__": |
| 28 | + weight = int(input("Weight of the patient in kg: ")) |
| 29 | + time = int(input("Enter the time of drink (in hour only): ")) |
| 30 | + vol = float(input("Volume percent of alcohol in the drink:")) |
| 31 | + amount = int(input("Enter the amount the you drank: ")) |
| 32 | + gender = str(input("You are man or woman: ")) |
| 33 | + |
| 34 | + BAC(weight,time,vol,amount,gender).result() |
0 commit comments