Coin flips

We will look into a coin flip, or coin toss, simulation using NumPy. For this purpose, we will use the randint function that comes in the random submodule from NumPy. This function takes the low, high, and size arguments, which will be the range of random integers that we want for the output. So, in this case, we want the output to be either 0 or 1, so the value for low will be 0 and high will be 2 but not including 2. Here, the size argument will define the number of random integers we want for the output, that is, the number of coins we will flip, in our case:

So we will assign 0 as tails and 1 as heads and the size argument is ...

Get Become a Python Data Analyst now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.