Python Forum

Full Version: While loop/half-life
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Carbon-14 is constantly produced in Earth’s upper atmosphere
due to interactions between cosmic rays and nitrogen, and is found in all plants and animals.
After a plant or animal dies, its amount of carbon-14 decreases by about .012%
per year. Determine the half-life of carbon-14, that is, the number of years required for
1 gram of carbon-14 to decay to less than ½ gram

I have to use while statement but I'm not sure how to do that without just using the formula? 
Any tips on the math for this problem?
What have you tried?
i wasthnking divide by 0.012%? or keep multplying by 0.0988% in the while loop
Okay, but what's the condition on the while loop going to be?
(Mar-06-2017, 02:27 AM)ichabod801 Wrote: [ -> ]Okay, but what's the condition on the while loop going to be?

while (carbon > 0.5)?
You're going to have to show more than a tentative first line.

while carbon > .5:
    # make some computations
The thing about learning is to try something and see if it works as expected, if it doesn't work, try something else.  Speaking for myself, I have more failures than successes.
(Mar-06-2017, 02:08 PM)sparkz_alot Wrote: [ -> ]Speaking for myself, I have more failures than successes.

100 failures could lead to one success.  ...and, once successful, you stop working.  The default state of any sort of engineering is that failure_count > success_count.