Question

Using Python: Assuming that: Caffeine is absorbed into the body immediately. Once absorbed, 20% is eliminated from the b...

Using Python: Assuming that: Caffeine is absorbed into the body immediately. Once absorbed, 20% is eliminated from the body each hour. Write a program that asks the user for the amount of coffee consumed, in milligrams (mg), and then compute (and output) the following: The number of hours required until there is less than half of the caffeine left in the body The amount of caffeine left in the body after 8 hours Then, assuming that the person drinks a cup of coffee at 8 am and then drinks a cup of coffee at the end of each hour until 6 pm, compute and output the following. How much caffeine will there be in the body at the end of the 10 hours? A sample run would be as follows. Enter the amount of caffeine in mg: 200 Less than half of it will be left after 4 hours. The amount of caffeine left in the body after 8 hours: 33.55 mg The amount remaining after 10 hours: 914.10 mg

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1.CODE:Below is the code in python

coffee = int(input("Enter the amount of  coffee consumed in mg: "))
remaining=coffee
hr=1
while(coffee/2 <= remaining*0.80):
    remaining=remaining*0.80
    hr=hr+1

for i in range(0,8):
    final=coffee*0.80
    coffee=final

intake=coffee
for i in range(0,10):
    intake= coffee+.80*intake


print("The number of hours required until there is less than half of the caffeine left in the body:",hr)
print("The amount of caffeine left in the body after 8 hours:",final)
print("The amount remaining after 10 hours:",intake)


2.Explanation
coffee variable will hold the value of input by the user
hr is the hour variable which will indicate the hours taken to half the input variable

while(coffee/2 <= remaining*0.80): This will determine the amount of hours until the input caffein becomes half.

after every hour 20% is absorbed by body so remainig values is 80% so in first hour 80% is remaining ,in second hours 64% is remainig(20% of 80%) and so on

for i in range(0,8):
    final=coffee*0.80
    coffee=final

This part will determine the amount left after 8 hours, i have run a loop from 0 to 8 ,after every hour the amount becomes 20% of previous value and final value will store the result

intake=coffee
for i in range(0,10):
    intake= coffee+.80*intake

This is an interested part, after every hour the person drinks one cup of coffee, so at 8 AM he drinks coffee

the amount remaining in body is 80% (as 20 % is absorbed by body).At 9 AM he drinks another cup of coffee

So at 9 AM total caffein amount is 80% of coffee he took at 8AM +the amount he took at 9 AM

and so on.

Add a comment
Know the answer?
Add Answer to:
Using Python: Assuming that: Caffeine is absorbed into the body immediately. Once absorbed, 20% is eliminated from the b...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The half-life of caffeine in the human body is about 6.5 hours. A cup of coffee...

    The half-life of caffeine in the human body is about 6.5 hours. A cup of coffee has about 105 mg of caffeine. a. Write an equation for the amount of caffeine in a person's body after drinking a cup of coffee? Let C be the milligrams of caffeine in the body after thours. b. How much caffeine will remain after 10 hours? mg c. How long until there are only 20 mg remaining? hours

  • % of the amount of caffeine in the body is metabolize A typical cup of coffee contains mg of caff...

    % of the amount of caffeine in the body is metabolize A typical cup of coffee contains mg of caffeine and every hour approximately and eliminate (a) Write C, the amount of caffeine in the body in mg as a function of time t, the number of hours since the coffee was consumed 2 Edit mg (b) How much caffeine is in the body after t = 10 hours assuming no other source of caffeine? Round your answer to two...

  • can anyone solve a , b and c part 7 Chapter Task The Half-Life of Caffeine...

    can anyone solve a , b and c part 7 Chapter Task The Half-Life of Caffeine Caffeine is a stimulant found in many products, such as coffee, tea, pop, and chocolate. When you drink a cup of tea or eat a chocolate bar, you ingest caffeine. Your body breaks down caffeine slowly. As with other drugs, caffeine has a half-life in the body. The half-life of caffeine in a typical nonsmoking adult is 5.5 h. Caffeine Content (mg) 250 mL...

  • -Is the rate of elimination of caffeine from the body linear or exponential? Explain your reasoning...

    -Is the rate of elimination of caffeine from the body linear or exponential? Explain your reasoning -Suppose a person starts the day by drinking 3 cups of coffee containing 130 mg of caffeine each. a. Let C = mg of caffeine remaining in the body and let t = hours since the 390 mg of caffeine was consumed. Write a function C(t) that expresses the amount of caffeine remaining in the body as a function of time. b.Determine how much...

  • A cup of green tea contains 32 mg of caffeine when you are using the tea...

    A cup of green tea contains 32 mg of caffeine when you are using the tea leaves for the first time. A cup from the second brew contains 12 mg of caffeine, while a cup from the third brew contains only 4 mg of caffeine. Caffeine leaves the body at a continuous rate of about 17% per hour. Write a differential equation for the amount, C, of caffeine in the body at time t hours after drinking the green tea....

  • can anyone help me as soon as possible second picture is for part D of the...

    can anyone help me as soon as possible second picture is for part D of the question 7 Chapter Task The Half-Life of Caffeine Caffeine is a stimulant found in many products, such as coffee, tea, pop,. and chocolate. When you drink a cup of ea or cat a chocolate bar, you ingest caffeine. Your body breaks down caffeine slowly. As with other drugs. caffeine has a halflife in the body. The half-life of caffeine in a typical nonsmoking adult...

  • A caffeine patch has been designed which releases 300 mg of caffeine over six hours. You...

    A caffeine patch has been designed which releases 300 mg of caffeine over six hours. You are concerned that this patch could pose serious health risks if accidentally left on as there is no way to control the caffeine release. The patch is applied to the shoulder where the skin is 1.5 mm thick. You also know that mass diffusivity from the caffeine through the skin is 6.8 x 10-8 cm/s. The patch itself is a 4 cm x 4...

  • Please show all work neatly! :) Thank you! Directions: Show all work, and answer each question...

    Please show all work neatly! :) Thank you! Directions: Show all work, and answer each question that is asked. Explanations should be given in complete sentences. All graphs should be drawn accurately on this sheet, and be fully labeled. 1. Rylin drinks a cup of coffee every morming at 7:00 am. The amount of caffeine (in mg) in her body as a result of drinking this coffee is given by the function A(t) 130 where t is time in hours...

  • plz, answer all questions clearly and correctly. i am begging you ex of activity? in a...

    plz, answer all questions clearly and correctly. i am begging you ex of activity? in a single intra exactly, what 3. A new drug was given in a single intravenous dose of 200 mg to an 80-kg adult male patient. After 6 hours, the plasma drug concentration of drug was 1.5 mg/100 mL of plasma. Assum- ing that the apparent V, is 10% of body weight, compute the total amount of drug in the body fluids after 6 hours. What...

  • Coffee Cravers Ignoring Bean-Price Surge for Caffeine Fix by Marvin G. Perez and Lynn Doan Coffee...

    Coffee Cravers Ignoring Bean-Price Surge for Caffeine Fix by Marvin G. Perez and Lynn Doan Coffee Cravers Ignoring Bean-Price Surge for Caffeine Fix Marvin G. Perez and Lynn Doan March 13, 2014, 5:17 PM EDT Doreen Cappelli is so hooked on her morning cappuccino that she says she’d pay a lot more to get it. “I don’t drink wine and alcohol,” Cappelli, 52, said after buying the $3.25 drink at Blue Bottle Coffee at San Francisco’s Ferry Building, in the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT