## Lesson goal: Probability with a coin

Previous: A list of numbers: Testing the standard deviation | Home | Next: Two coin tosses (1)

In this section, we'll look at some code and lessons that will help you to learn about the chance (or the probability) that something will happen. We'll use coin tosses and rolls of a dice since they're so familiar. Let's get started.

To begin, we'll simulate a coin toss here using the math.random function covered in a past lesson. We'll call math.random(1,100), and assume a "head" if the result is $<50$ and tails is the result is $\ge 50$.

What we'd like to do here is to see how many heads and tails we'd get when we toss a coin a few times, say 4 times. You probably already know the answer, but let's look anyway.