0

# In this activity we will code an unfair coin to demonstrate probability with the MicroBit.

It was announced this morning that MicroBit is launching an educational foundation and educators across the globe will be able to get their hands on this gadget. As such, we will build a quick app to demonstrate an unfair coin.

In theory, flipping a coin yields a 50/50 chance of returning heads or tails. We can simulate this by using the Random function found inside coding languages. Here’s how it works.

If (Pick Random Number Between 0 and 1) Returns 1 Then Show “Tails”
Else Show “Heads”

However, because we want to make an unfair coin, we will make our range larger.

If (Pick Random Number Between 0 and 2) Returns 1 Then Show “Tails”
Else If (Pick Random Number Between 0 and 2) Returns 2 Then Show “Tails”
Else Show “Heads”

You’ll notice from the above example we have changed the theoretical probability of this similar to be 66/33. This means for every Heads, we should have two tails.

# For more lessons, activities and ideas, grab a copy of my book, Code Breaker, on Amazon here!

(Visited 748 times, 1 visits today)