Question

In: Computer Science

This should be in Python Statement : A lot of people drink and drive. The legal...

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.

Solutions

Expert Solution

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))


Related Solutions

How important is lot sizing? How should managers choose an Appropriate lot size? Should it be...
How important is lot sizing? How should managers choose an Appropriate lot size? Should it be chosen strictly on economic basis, or should intangible factors be considered.
Dr. Wind is interested in whether weather influences how people drive. She has 30 people drive...
Dr. Wind is interested in whether weather influences how people drive. She has 30 people drive in three different weather conditions (10 drive in sunny conditions, 10 drive in foggy conditions, and 10 drive in rainy conditions) and measures how fast they drive on the freeway. 1. What is the IV? How many levels does it have? Please name the levels. Is it between- or within-subjects? 2. What is the DV? What is its scale of measurement? 3. What is...
Write the following Python script: Problem Statement We want to know how many different people have...
Write the following Python script: Problem Statement We want to know how many different people have eaten at a restaurant this past week. The parameter meals has strings in the format "name:restaurant" for a period of time. Sometimes a person eats at the same restaurant often. Return the number of different people who have eaten at the eating establishment specified by parameter restaurant. For example, "John Doe:Moes" shows that John Doe ate one meal at Moes. Write function howMany that...
The ice rink is very crowded, and there are a lot of inexperienced people learning to...
The ice rink is very crowded, and there are a lot of inexperienced people learning to ice skate there. Tara is originally skating at 4.5 m/s and collides with Sarah who is at rest. After the collision, they hang on to each other in an effort to not fall over. They are no longer watching where they are going and end up running into Millicent who was just standing there. Then they all hang on to each other to avoid...
In Python, suppose you had: >>> a_name = 'Byb' Then is this legal? >>> a_name[1] =...
In Python, suppose you had: >>> a_name = 'Byb' Then is this legal? >>> a_name[1] = 'o' _________________ If not why not? _________________
Should insider trading be legal? Why or why not?
Should insider trading be legal? Why or why not?
Given that 58% of people don’t drink enough water in a day, in a SRS of...
Given that 58% of people don’t drink enough water in a day, in a SRS of 150 people what is the probability that between 55% and 60% of the sample don’t drink enough water? 0.05 0.12 0.31 0.46
The amount of coffee that people drink per day is normally distributed with a mean of...
The amount of coffee that people drink per day is normally distributed with a mean of 14 ounces and a standard deviation of 5 ounces. 32 randomly selected people are surveyed. Round all answers to 4 decimal places where possible. What is the probability that one randomly selected person drinks between 13.7 and 14.1 ounces of coffee per day? For the 32 people, find the probability that the average coffee consumption is between 13.7 and 14.1 ounces of coffee per...
The amount of coffee that people drink per day is normally distributed with a mean of...
The amount of coffee that people drink per day is normally distributed with a mean of 17 ounces and a standard deviation of 7 ounces. 34 randomly selected people are surveyed. Round all answers to 4 decimal places where possible. What is the distribution of X? X ~ N(___,___) What is the distribution of ¯x? ¯x ~ N(___,___) What is the probability that one randomly selected person drinks between 16.5 and 17.3 ounces of coffee per day? For the 34...
The amount of coffee that people drink per day is normally distributed with a mean of...
The amount of coffee that people drink per day is normally distributed with a mean of 15 ounces and a standard deviation of 7 ounces. 33 randomly selected people are surveyed. Round all answers to 4 decimal places where possible. What is the distribution of X ? X ~ N( , ) What is the distribution of ¯ x ? ¯ x ~ N( , ) What is the probability that one randomly selected person drinks between 14.6 and 15.5...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT