WeCodeAcademy

Probability Basics

Probability is a number from 0 (impossible) to 1 (certain). For equally likely outcomes it is favourable / total. Rolling a die: the chance of an even number is 3/6 = 0.5.

You can also estimate a probability by simulation: repeat the experiment many times and see how often the event happens. With a seed the result is repeatable.

Examplepython
Open in editor »
Quick check

What is the probability of rolling a number greater than 4 on a fair die?

Your turn: write the code

Estimate by simulation the chance that a single die roll shows 5 or 6, rounded to 2 decimals.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.