A classic GCSE Physics experiment using plastic cubes to model random radioactive decay can be modelled and simulated with Python.
You can change the number of starting cubes by editing the line max_count = 100
The whole experiment is carried out before displaying any results!
The results are saved to a file called decay_graph
#!/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()