+0  
 
0
174
3
avatar+175 

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
Maplesnowy  Jun 14, 2018
 #1
avatar
0

So, what is the question??.

Guest Jun 14, 2018
 #2
avatar+84 
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)

ChowMein  Jun 14, 2018
 #3
avatar+175 
0

tytytytytyt

Maplesnowy  Jun 16, 2018

48 Online Users

avatar
avatar
avatar

New Privacy Policy

We use cookies to personalise content and advertisements and to analyse access to our website. Furthermore, our partners for online advertising receive information about your use of our website.
For more information: our cookie policy and privacy policy.