This is a Monte Carlo Simulation question. Here is my code.
def simulate():
"""
Simulate three dice and return true if sum is > 10
"""
die_1 = randint(1,6)
die_2 = randint(1, 6)
die_3 = randint(1,6)
sum = die_1 + die_2 + die_3
if sum > 10:
return True
else:
return False
The next steps are to use a for loop and call the simulate function to sum up the number of results that end up as True. My idea of doing this:
true_results = 0
for trial in range(1000):
true_results += simulate()
However, how would I determine what is a True or False result? And does this code make sense?