0

Blocks become code

  1. move right
    move right
    collect the star

    Blocks you know

    Here is a program you can read. The robot moves right two times. Then it grabs the star. Tap Run the program to watch.

  2. move_right()
    move_right()
    collect()

    The same program as code

    This is the very same program, written as code. Each block is one line. The block move right is move_right(). The collect block is collect().

  3. move_right()
    The robot knows this
    move right
    The robot is stuck

    Spell it just right

    The computer is very fussy. Put a low line between the two words. End with two round brackets. Then the robot understands.

  4. repeat 3 times
    move down
    collect the star

    A repeat block

    This program has a repeat block. The robot moves down three times. Then it grabs the star.

  5. repeat 3:
        move_down()
    collect()

    Repeat as code

    The repeat block becomes repeat 3: with a colon at the end. The lines inside move in four spaces. That shows they belong to the repeat.

  6. move_up()
    move_right()
    move_right()
    collect()

    You can read code

    Count the lines. Each line is one block. Next year you will type lines like these yourself.

For parents

Goal: Your child sees that each block is really one line of code, like move_right() or repeat 3:. This is the last Grade 2 lesson and gets them ready to type code in Grade 3. Three labs follow: build with blocks while a See it as code panel shows the lines, guess where a program stops, and build a repeat program.

  • In the robot labs, open See it as code and point to each line. Ask: which block is this?
  • Spell move_right() together, with the low line and the two brackets.
  • Ask: how many lines are there? That is how many blocks there are.

Away from the screen: Write move_up(), move_down(), move_left() and move_right() on four cards. Hold one up, and your child takes one step that way.

Coding · Computers and Code
Back to top