AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Meet the floor robot

Week 4 · 1.2 Floor robot beginnings · 3 lessons
3

From algorithm to code

Computing 1: Topic 1.2, pp. 19–32
GoalChange an algorithm in words into code with command cards.
New words
code · instructions in a language a robot understandsalgorithm · steps in words; we change them into code
Explanation

First we plan with words. This is the algorithm. A robot cannot read words. So we change the words into code. Code is a row of command cards. Each step in the algorithm becomes one card. We read the cards in order, from left to right.

algorithm in wordschange itcode for the robot
Worked examples
forwardforwardturn leftforwardforwardforwardGOGO
Algorithm: forward two steps, turn left, forward three steps. The code is F F L F F F. We press GO at the end.
backbackturn right
Algorithm: back two steps, turn right. The code is B B R.
backturn leftforward
Read this code: B L F. In words: back, turn left, forward.
Class activity

Code translator: one person says an algorithm out loud, such as ‘forward two, turn right, forward one’. The other lays out command cards for it. Check each card, left to right. Then swap and make a new algorithm.

Practice
1
Write the code for: forward two steps, turn right.
2
Say this code in words.
3
What is the word for instructions a robot understands?
4
Which way do we read the command cards: left to right or right to left?