Unit 2.1: MakeCode: Block Types

In MakeCode, there are lots of bright colours, and funky block shapes.
They aren’t just for looks – the colour and shape of a block tells you a lot about it.

You can right-click on any block in the editor and click on ‘Help(try it) to bring up an explanation of how that block works.

Colours are Categories

On the left side of the editor window are several coloured categories – each one holds similar blocks.
Click on a category to open it. (You can also use the ‘search’ function if you remember the name of a block but not where to find it)

If a block in the window is grey, that means it’s inactive – it won’t be included in your program.
Each of the categories has a help page; look through them to learn more.

Shapes have Meaning

MakeCode is a little bit like a Lego kit; blocks snap into each other in many many ways.
If you try to put a block where it doesn’t belong, the editor will stop you.
(or the block will stay grey and disconnected)

There are only FOUR basic shapes:

1. Statements

Statement block has puzzle-piece-marks on the top and bottom.
  1. A Statement is one step / one instruction / one action. It means “Do this.”
  2. Statements can be snapped together into a list.
  3. A list of Statements is run; in order, one after the other, from top to bottom.
  4. Statements have to live inside a Container.
    (If placed anywhere else, the Statement will be disabled and greyed out)

2. Containers

A Container block has puzzle-piece-marks inside it.
  1. A Container holds statements inside it.
    Containers can stretch to hold any number of statements, or even be empty.
  2. Container lets you choose when to run those statements.

    eg: the forever container block runs the statements inside it over and over again.
    eg: the on Shake container block runs the statements inside it once each time the board is shaken.
  3. Some Container blocks have puzzle-piece-marks on the outside too.
    These blocks are both a Container and a Statement; 

    1. They hold any number of statements inside, but
    2. They have to live inside another container.

    eg: the if container block runs the statements inside it only if the boolean condition at the top is true.

3. Expressions

An Expression has rounded ends
  1. An expression is a block or set of blocks that represent a value.
    (Usually a number, but there are other types)
  2. These expressions are passed into other blocks to control them,

    eg: in this repeat block, the expression 4 controls how many times the ‘jump up’ sound plays.
  3. Expressions have a lot of power and flexibility.
    1. The Math category lets you build and combine many kinds of expression, like a mathematical equation.
    2. The Variables category (which we’ll learn more about later) lets us store information in memory and build complex behaviour.
    3. Every other category has expressions too; the Input category has sound level,  Music has tempo (bpm), etc.

4. Boolean

Booleans have pointed ends
  • Boolean is one of two possible values; true or false.
  • Logical blocks like and, or, not combine inputs in a Boolean way and make another Boolean value:

    eg: the ‘shouldIMisbehave‘ variable will be set to true if ‘isBored‘ is true andteacherIsLooking’ is false, otherwise it will be false.

    isBored teacherIsLooking shouldIMisbehave
    false false false
    true false true
    false true false
    true true false


  • Comparison blocks like =, , let you compare values numerically, and make a Boolean value:

    eg: the comparison block above will be set to true if ‘dice_roll’ is 5 or higher, otherwise it will be false.

    dice_roll dice_roll ≥ 5
    3 false
    4 false
    5 true
    6 true


  • Booleans are often used to control Containers like if and while – to control whether the program should run steps inside them, and if so how many times.



There are only four basic kinds of block, but like Lego there are many many ways they can go together.
Figuring out the best way to accomplish something takes practice – nobody is an expert overnight.

Student Exercise

For each of the blocks below, are they a Statement, a Container, an Expression or a Boolean?
Write the answers in your worksheet.


Forever Block
5 Block
On Shake Block
True Block
Pause Block
And Block
If Block
Show Ring Block
On Start Block
Pick Random Block
Variable Block
Plus Block
If-Else Block
Play Tone Block
Repeat Block
Set Light Block
If-ElseIf-Else Block
Was Pressed Block


Next: Unit 2.2: MakeCode: Remembering Stuff with Variables

Back to Programming