Code: instructions for a computer
Cartoons, films and video games are made with code. Coding, or programming, means writing many algorithms to build a whole program. A program is like a whole cookbook, and each recipe in it is an algorithm. People talk to each other in languages such as Arabic and English. Computers use programming languages, and there are many of them. A computer follows your instructions exactly and cannot guess what you meant. If you tell a robot friend “walk”, it does not know how far or where. So code needs exact instructions: how many steps and in which direction.
| What I say to a friend | What I must tell a computer |
|---|---|
| Go to the door. | Turn right, walk 5 steps, then stop. |
| Draw a square. | Draw a line, turn a quarter turn, and repeat that 4 times. |
| Wait a little. | Wait 2 seconds. |
Robot and programmer. Work in pairs: one is the programmer and the other is the robot. The programmer gives exact commands only from this list: forward 1, turn left, turn right. The robot must obey exactly, even if it looks funny. The goal is to walk from your seat to the door. Then swap roles. What happened when a command was not exact?