Advertisement
Antypas

function 2 dice roll

Apr 10th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import random
  2. def two_dice(numRolls):
  3.     outcome = []
  4.     for index in range(11):
  5.         outcome.append(0)
  6.     counter = 1
  7.     while counter <= numRolls:
  8.         rollsum = random.randint(1,6) + random.randint(1,6)
  9.         print("Roll number ", counter, "is -> ", rollsum)
  10.         outcome[rollsum-2] = outcome[rollsum-2] + 1
  11.         counter = counter + 1
  12.     frequency = []
  13.     for index in range(11):
  14.         frequency.append(outcome[index]/numRolls)
  15.     return outcome, frequency
  16.    
  17. outcome2Dice, frequency2Dice = two_dice(10)
  18. print(outcome2Dice)
  19. print(frequency2Dice)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement