CodeHS 4.3.5: Rolling Dice , the goal is typically to take two dice values from a user and determine if they "rolled doubles" using comparison operators. Depending on whether you are using JavaScript , the implementation differs slightly. Python Solution In the Python version, you use
for _ in range(num_rolls): roll = roll_die() outcomes[roll - 1] += 1 codehs 4.3.5 rolling dice answers
def probability_sum_3(): """Calculates the probability of rolling a sum of 3 with two dice""" count = 0 total = 0 for _ in range(10000): die1, die2 = roll_two_dice() if die1 + die2 == 3: count += 1 total += 1 return count / total CodeHS 4
Unlike many other Python functions, randint is inclusive. If you put (1, 6), it can actually roll a 6. If you put (1, 6), it can actually roll a 6
If your code isn't passing the CodeHS autograder, check the following: