bobhig

dice_roll function

Jan 23rd, 2019
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #return results of n rolls of 2 dice
  2. #first 2 values in list will always be 0
  3.  
  4. import random
  5.  
  6. values = [0,1,2,3,4,5,6,7,8,9,10,11,12]
  7.  
  8. def dice_roll(number_of_rolls):
  9.  
  10.     totals = [0] * 13
  11.  
  12.     for i in range(number_of_rolls):
  13.  
  14.         dice_1 = random.randint(1,6)
  15.         dice_2 = random.randint(1,6)
  16.  
  17.         total = dice_1 + dice_2
  18.  
  19.         totals[total] = totals[total] + 1
  20.  
  21.     return totals
  22.  
  23.  
  24. print(list(enumerate(dice_roll(24))))
RAW Paste Data