-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdices.py
More file actions
37 lines (31 loc) · 675 Bytes
/
Copy pathdices.py
File metadata and controls
37 lines (31 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from random import randint
import pandas as pd
dice1 = []
dice2 = []
nr_dices = 100000
for i in range(nr_dices):
throw1 = randint(1,6)
throw2 = randint(1,6)
dice1.append(throw1)
dice2.append(throw2)
summed = []
for i in range(len(dice1)):
s = dice1[i] + dice2[i]
summed.append(s)
counts = {}
for c in range(2, 13):
counts[c] = 0
for s in summed:
counts[s] = counts[s] + 1
data = []
for c in counts:
data.append({
'value': c,
'counts' : int(counts[c]),
'percentage': round(
counts[c] / nr_dices * 100,
2
)
})
df = pd.DataFrame(data).set_index('value').astype(int)
df.transpose().to_csv('assets/dices.csv')