In [78]:
import random
import numpy as np
import matplotlib.pyplot as plt
def rollDice():
roll1 = random.randint(1,6)
roll2 = random.randint(1,6)
return roll1+roll2
x = 0
nums=[]
while x < 1000:
result = rollDice()
nums.append(result)
x+=1
plt.hist(nums, rwidth=0.75, bins=12)
plt.title("Sum of Rolling Two Dice")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
"""def simple_wager(wage):
turn=rollDice()
while wage>0:
if turn>=2 and turn<4:
wage=wa
print(wage)
elif turn>=4 and turn<=10:
wage-=200
print(wage)
elif turn>10:
wage+=20
print(wage)
print (simple_wager(100))"""
Out[78]:
In [ ]: