2
Draw a letter
Computing 2: Unit 8, pp. 106–121
GoalWrite an algorithm for a robot with a marker to draw a letter or a number.
New words
marker · a pen on a robot that draws a line as it movesmarker down · the robot draws a line when it movesmarker up · the robot moves without drawing
Explanation
Some robots hold a marker. With the marker down, the robot draws a line as it moves. With the marker up, it moves without drawing. To draw a letter, we write an algorithm. It starts, puts the marker down, moves and turns, and stops. The robot draws only what we tell it to draw.
| Step | Instruction |
|---|---|
| 1 | Start |
| 2 | Marker down |
| 3 | Forward 4 |
| 4 | Turn left |
| 5 | Forward 2 |
| 6 | Turn left |
| 7 | Forward 4 |
| 8 | Stop |
Worked examples
The robot follows the algorithm above. It starts at the top left, facing down. It draws the letter U.
What if step 2 is left out? The robot walks the same path but the marker is up, so it draws nothing. The grid stays empty.
Another algorithm: start, marker down, forward 2, turn right, forward 4, stop. The robot starts at the top left, facing right. It draws the number 7.
Class activity
Draw with a marker robot: draw a grid of 3 columns and 5 rows on a big sheet of paper. Choose one child to be the robot with a crayon. The crayon on the paper means “marker down” and a lifted crayon means “marker up”. A partner reads the algorithm for the letter U one step at a time. Then try the algorithm for the number 7. (You can also use a pencil and your own finger on squared paper.)
Practice
1
The algorithm for the number 7 is: start, marker down, forward 2, turn right, forward 4, stop. Change one step so that the top line of the 7 is 3 squares long.
Change step 3 from forward 2 to forward 3.
2
What happens if “marker down” is missing from an algorithm?
The robot moves along the path, but it draws nothing.
3
The robot draws this letter. Which letter is it?
J.
4
Count the steps in this algorithm: start, marker down, forward 4, turn left, forward 2, turn left, forward 4, stop.
8 steps.