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
Trackbacks for this entry [ Trackback URL ]
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
-
-
Python worm?on Jun 27 2013 09:21 AM
-
Credit card Encrypter in Python using the CVD and Expiration dateon May 15 2013 06:32 PM
-
Radioactive half life converter thing?on Feb 24 2013 03:11 PM
-
back from break, well sort of...on Jul 10 2012 07:59 AM
Search My Blog
5 user(s) viewing
5 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment









|