Advertisement
Guest User

Average of rolling two dice and taking the higher value

a guest
Mar 7th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. allCombinations = []
  4.  
  5. for x in range(6):
  6.     firstDie = x+1
  7.     for y in range(6):
  8.         secondDie = y+1
  9.         maxValue = max(firstDie, secondDie)
  10.         allCombinations.append(maxValue)
  11.  
  12. average = float(sum(allCombinations)) / float(len(allCombinations))
  13.  
  14. print("Average roll: %s" % (average))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement