Coding an Unfair Coin Simulator With MicroBit

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.

Future-ready students need to be creative. They need to know how to communicate their ideas and how to collaborate as problem solvers. To master these and other twenty-first-century requirements, they will need to be critical thinkers.

You don’t have to be a “computer geek” to empower your students with these essential skills. Code Breaker equips you to use computational thinking and coding in your classroom – regardless of your computer skill level – to increase creativity, remix assessment, and develop a class of coder ninjas!