Lesson 8: Rolling the dice

posted Dec 12, 2019, 7:59 AM by Attila Lengyel
import random as r

print("Let's roll the dice!")
roll = r.randint(1,6)
print("I rolled ", roll)

rolls = [0,0,0,0,0,0]

for x in range(0, 100):
roll = r.randint(1,6)
rolls[roll-1] = rolls[roll-1] + 1

print(rolls)

rolls2 = [0,0,0,0,0,0,0,0,0,0,0,0]

for x in range(0,1000000):
roll1 = r.randint(1,6)
roll2 = r.randint(1,6)
num = roll1 + roll2
rolls2[num-1] = rolls2[num-1] + 1

for x in range(0,12):
print(x + 1, ":", rolls2[x])



Comments