CoCalc Public FilesProject / S21 / Final Project Draft / Code For project 4.ipynbOpen with one click!

1

2

In [1]:

import numpy as np

3

4

In [2]:

D1= np.random.randint(1,7) D2=np.random.randint(1,7) D3=np.random.randint(1,7) D4=np.random.randint(1,7)

5

6

7

In [3]:

def dice_rolls(): D1= np.random.randint(1,7) D2=np.random.randint(1,7) D3=np.random.randint(1,7) D4=np.random.randint(1,7) if (D1+D2==7 and D3+D4==9) or (D1+D2 ==9 and D3+D4==7): return 1 elif (D2+D3==7 and D1+D4==9) or (D2+D3 ==9 and D1+D4==7): return 1 elif (D2+D4==7 and D1+D3==9) or (D2+D4 ==9 and D1+D3==7): return 1 else: return 0

8

9

In [5]:

sum([dice_rolls() for i in range(10000)])/10000

10

0.0778

11

In [ ]:

12