fork download
  1. from random import randint as rd
  2.  
  3. z = [0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]
  4. y = {}
  5.  
  6. for _ in range(1000000):
  7. a = rd(1, 6)
  8. b = rd(1, 6)
  9. c= a + b
  10.  
  11. if c not in y:
  12. y[c] = []
  13. y[c].append((a, b))
  14. else:
  15. y[c].append((a, b))
  16.  
  17.  
  18. y = dict(sorted(y.items()))
  19.  
  20. for k in y:
  21. print("%2d: %6.4f (%6.4f)" %(k, len(y[k])/1000000, z[k]/36))
  22.  
Success #stdin #stdout 2.42s 81560KB
stdin
Standard input is empty
stdout
 2: 0.0275 (0.0278)
 3: 0.0559 (0.0556)
 4: 0.0828 (0.0833)
 5: 0.1115 (0.1111)
 6: 0.1391 (0.1389)
 7: 0.1668 (0.1667)
 8: 0.1393 (0.1389)
 9: 0.1108 (0.1111)
10: 0.0828 (0.0833)
11: 0.0557 (0.0556)
12: 0.0277 (0.0278)