Let's roll a pair of dice two times. What is the probabiblity of not getting a 7 or 11 total on either of two tosses?
We'll set N equal to the number of rolls we'd like to make. Next, we'll set up a for-loop that will roll each die N times, add their numbers and see if the sum is $7$ or $11$.
Now you try. Choose a value for N, then fix the if statement to look for a sum of 7 or 11.
Type your code here:
See your results here:
Here's a way of assessing this answer. This table represents all 36 ways two die can be rolled.
(1,6)
(2,6)
(3,6)
(4,6)
(5,6)
(6,6)
(1,5)
(2,5)
(3,5)
(4,5)
(5,5)
(6,5)
(1,4)
(2,4)
(3,4)
(4,4)
(5,4)
(6,4)
(1,3)
(2,3)
(3,3)
(4,3)
(5,3)
(6,3)
(1,2)
(2,2)
(3,2)
(4,2)
(5,2)
(6,2)
(1,1)
(2,1)
(3,1)
(4,1)
(5,1)
(6,1)
For example, $(5,2)$ means die one ended up with a $5$ and die 2 ended up with a $2$. If you look carefully, you'll count $8$ combinations (of 36 total) that result in a $7$ or $11$ (see the diagonal elements and the $(5,6)$ and $(6,5)$ in the upper right).
Now, $8$ in $36$ is a probability of $8/36$ or $2/9$. Thus, the chance of NOT getting a $7$ or $11$ is $1-2/9=7/9$. This is after the dice are rolled just once. (If you don't like the "1-" bit, count all pairs that do not sum to 7 or 11. There are 28 of them, or a $28/36=7/9$ (same answer) chance of NOT rolling a 7 or 11.)
Since the second toss of the dice is independent of the first roll, we use the "and" idea again: "no 7 or 11 after the first toss, AND no 7 or 11 after the second toss." This means we multiply $7/9\times 7/9$ and get $49/81=0.6$.
Share your code
Show a friend, family member, or teacher what you've done!