Lesson goal: Probability with two coins (2)

Previous: Two coin tosses (1) | Home | Next: Throwing two dice

Like the last lesson, let's toss two coins, but now look for the chance the results will either be HT or TH.

We'll reuse a function called toss() which handles all of the tossing mechanics of a coin, just returning a 'h' for heads or 't' for tails. We'll put results for coin 1 and coin 2 into their respective variables, then put them together into a third variable called both that will end up being either: hh, tt, ht, or th. We'll count the number of times both comes out to be ht or th.

Now you try. Finish the code, in particular the N= line and the line that looks to see if the toss() function returns an 'h' both times.

Type your code here:


See your results here: