Lesson 23: Rolling the dice

posted Apr 20, 2018, 7:57 AM by Attila Lengyel
import random

def dice():
  roll = random.randint(1,6)
  return roll
  
statistics = {1:0,2:0,3:0,4:0,5:0,6:0}
for x in range(0,600):
  roll = dice()
  statistics[roll] += 1

print(statistics)

sumstat = {}
for x in range(2,13):
  sumstat[x] = 0

trials = 11000
for x in range(0, trials):
  roll = dice() + dice()
  sumstat[roll] += 1

for x in range(2,13):
  print(x, "'s probablity is", 100*(sumstat[x]/trials), "%")


  

Comments