def leastProb(particles): '''particles is a dictionary with particle names as keys and probabilities as values. Return the particle that is the least probable''' leastval = 2 for p in particles: print("Testing particle",p) print("lastval so far is",leastval,"particles[p] is",particles[p]) if particles[p] < leastval: leastval = particles[p] leastname = p print("=> updated leastval to",leastval) print("=> updated leastname to",leastname) return leastname def main(): # The probabilities of detecting certain types of subatonic particles particles = {'neutron':0.55,'proton':0.21,'meson':0.03,'muon':0.07,'neutrino':0.14} print("the least probable particle is",leastProb(particles)) main()