In: Computer Science
This should be in Python
Statement :
A lot of people drink and drive. The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. This program could potentially help users estimate how long to wait before driving, if they must drive.
Program Description
This program will:
Give the most recent statistics of drinking and driving in California. It will allow user to create an account. The program will also save the users name, weight, age, and height. It will give the user the option of adding an emergency contact. Program will prompt user for what type of alcohol they are consuming as well as the oz and percentage of alcohol in that drink. The program will use that data to calculate how many drinks they can have to stay under the .08%. If the program estimates that they could be over the alcohol level, it will warn the user. The warning will include links to driving services such as Uber, Lyft, etc. And it will give the user the option to generate a message to their emergency contact.
def problemfour():
try:
gender = int(input("What
is your gender? Enter 1 for Male, 0 for Female"))
weight = int(input("What
is your weight?"))
drinks = int(input("How
many drinks have you had?"))
volume = int(input("What
is the alcohol by volume per drink (in oz)?"))
time = int(input("When
was your last drink(in hours)"))
except ValueError as e:
print("You have entered
an incorrect value. ")
total_alcohol = drinks * volume
#The below changes the ratio depending on if the
user is a male or female.
if gender == 1:
ratio = 0.73
else:
ratio = 0.66
bac = round((total_alcohol * 5.14 / weight *
ratio) - 0.015 * time, 3)
#The below is used to create only 1 output
statement.
if bac >= 0.08:
variable = "not "
else:
variable = ""
print("Your BAC is {}".format(bac))
print("It is {}legal for you to
drive".format(variable))