Subscribe to thetrh51

## Radioactive half life converter thing?

Hey guys, here is some code I dreamed up regarding half lives of radioactive isotopes. With a known half life and a known mass you can calculate how much will be left after x years. It accepts negative years too but the formatting at the end is a little off when you do that.

```#halflife generator
import math as math
halflife = input("Please input the halflife of a radio active substance in years: ")
grams = input("How many grams of the radioactive substance are there? ")
print "Based on an exponential model, the equasion would be: f(years)=grams * 1/2^years/halflife"
print " "
years = input("How many years in the future do you wish for me to focus my crystal ball? ")
halfyears = years/halflife
x = math.pow(0.5, halfyears)
ans = grams * x
print " "

print 'My crystal ball projects that in ' + str(years) + ' years you will have ' + str(ans) + ' of ' + str(grams) + ' grams left of the original substance.'

```

### 0 Comments On This Entry

There are no Trackbacks for this entry

S M T W T F S
1234567
891011121314
15161718192021
2223 24 25262728
2930