+0  
 
0
3153
3
avatar+195 

Write a program that simulates rolling two 6-sided dice 1000 times, and keeps track of how many times each sum occurs. Then your program should print out a table of the number of times it rolled each sum from 2 through 12.

A sample run might produce the following output (your exact numbers will almost certainly not be the same as these):

Roll         Number

--------      -----------

2                  22

3                   58

4                   74

5                   121

6                    134

7                    143

8                     159

9                    106

10                   86

11                   73

12                   24

off-topic
 Jun 14, 2018
 #1
avatar
0

So, what is the question??.

 Jun 14, 2018
 #2
avatar+154 
0

Here's my solution to it, I've only self taught myself so don't mind the inefficiency of it cheeky 

import random

listOfSums = []
countOfSums = []
for i in range(1000):
    roll1 = random.randint(1,6)
    roll2 = random.randint(1,6)
    listOfSums.append(roll1 + roll2)
for roll in range(2, 13):
    countOfSums.append([roll, listOfSums.count(roll)])
print("[Roll, Number]")
for item in countOfSums:
    print(item)

 Jun 14, 2018
 #3
avatar+195 
0

tytytytytyt

Maplesnowy  Jun 16, 2018

0 Online Users