Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Modelling radioactive decay
#!/usr/bin/env python
## sudo apt-get install gnuplot-x1
from random import randint
particles = [] ## create an empty list
results = [] ## create a blank list for the results
max_count = 100 ## start with this number of cubes
while (max_count > 1) :
for i in range (max_count): ## populate array with random dice throws
face = randint(1,6)
for items in particles: ## read the array back and remove 'face up'
if items == 6:
max_count -=1
particles = [] ## reset particles list
graph = open("decay_graph", "w")
print ("The results from the experiment")
print ("--- ------- ---- --- ----------")
print ("\n")
for items in results:
graph.write(str(c) + " " + str(items) +"\n")
print (str(c) + " " + str(items))
c +=1
print ("\n")
print ("Displaying your graph with gnuplot")
print ("---------- ---- ----- ---- -------")
print ("\n")
print ("If you have not installed gnuplot then install it now: sudo apt-get install gnuplot-x1")
print ("\n")
print ("Start up a terminal window and naviage to home/pi/documents")
print ("\n")
print ("Start gnuplot")
print ("""plot "decay_graph" """)
print ("\n")
print ("Going further")
print ("Go back to the code and try increasing the original starting number of cubes")

uktechreviews commented Feb 22, 2017

first commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment