Skip to content

Instantly share code, notes, and snippets.

@uktechreviews
Last active July 30, 2017 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uktechreviews/db962b6cc6738033cf35507f4f1d546d to your computer and use it in GitHub Desktop.
Save uktechreviews/db962b6cc6738033cf35507f4f1d546d to your computer and use it in GitHub Desktop.
Modelling radioactive decay
#!/usr/bin/env python
from random import randint
particles = [] ## create an empty list
results = [] ## create a blank list
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)
particles.append(face)
for items in particles: ## read the array back and remove 'face up'
if items == 6:
max_count -=1
particles = [] ## reset particles list
results.append(max_count)
graph = open("decay_graph", "w")
print ("The results from the experiment")
print ("--- ------- ---- --- ----------")
print ("\n")
c=1
for items in results:
graph.write(str(c) + " " + str(items) +"\n")
print (str(c) + " " + str(items))
c +=1
graph.close()
@uktechreviews
Copy link
Author

first commit

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