-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackend.py
More file actions
26 lines (19 loc) · 915 Bytes
/
Backend.py
File metadata and controls
26 lines (19 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__author__ = 'Derek'
class Alcoholic():
def __init__(self, name, weight, standard_drinks, hours, gender):
self._name = name
self._weight = weight
self._gender = gender
self._standard_drinks = standard_drinks
self._hours = hours
def __str__(self):
return "My name is " + self._name + "and I drank " + self._standard_drinks + \
"servings of alcohol in " + self._hours + " hours."
def calc_bac(self):
if self._gender == "Male":
gender_value = 0.68
else:
gender_value = 0.55
bac = (float(self._standard_drinks) * 0.06 * 100 * (1.055 / float(self._weight)) * gender_value)\
- (0.015 * float(self._hours))
return "Your blood alcohol content is " + str(bac)