Last active
July 30, 2017 12:58
-
-
Save uktechreviews/db962b6cc6738033cf35507f4f1d546d to your computer and use it in GitHub Desktop.
Modelling radioactive decay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
first commit