Skip to main content
โ† Back to Traditional Coding samples
โŒจ๏ธTraditional Codingยท15 minยทSample Lesson

Giving Computers Orders: Writing Your First Code Instructions

Imagine you have a robot dog. If you say 'Sit!' it sits. If you say 'Fetch!' it runs to get the ball. Computers work the same way โ€” they do exactly what you tell them, step by step. Those instructions are called CODE!

What You'll Learn

After this lesson, you will be able to: 1. Explain what code is in your own words 2. Put instructions in the right order (this is called a sequence) 3. Spot a loop โ€” when a computer does the same thing over and over 4. Find and fix a simple bug in a set of instructions

What Is Code?

Code is a list of instructions you write for a computer. The computer reads your instructions from top to bottom, one at a time โ€” it never skips! Here are three code steps for a robot cat: Step 1: Move 10 steps forward Step 2: Turn right Step 3: Move 10 more steps forward If you swap Step 1 and Step 2, the cat moves in a completely different direction. Order matters a lot!

Computers Are Very Literal

A computer does exactly what you say โ€” nothing more, nothing less. If you forget a step, it cannot guess what you meant. This is why programmers write every step carefully!

Sequences: Steps in the Right Order

A sequence is a group of steps done in order. Think about getting dressed in the morning: 1. Put on your shirt 2. Put on your pants 3. Put on your shoes If you put your shoes on FIRST, the other steps become very tricky! Code sequences work the same way โ€” the order you write your instructions is the exact order the computer follows them.

๐ŸŽฏ

PB&J Robot Challenge

Pretend you are programming a robot to make a peanut butter and jelly sandwich. Write at least 6 steps on paper, in order. Be VERY specific โ€” the robot does not know what a sandwich is and cannot guess. Include: getting the bread out, opening the jar, spreading peanut butter on one slice, adding jelly to the other slice, and pressing them together. When you are done, read your steps aloud to a friend or family member and have them act out your instructions exactly as written. Did any steps need fixing?

Loops: Do It Again!

Sometimes you want the computer to do the same thing many times. Instead of writing 'Hop!' ten times in a row, you write a LOOP: Repeat 10 times: Hop! That is much shorter and easier to read. Real video games use loops to redraw the screen 60 times every second so everything looks smooth and fast. Without loops, game code would be millions of lines long!

โ“

Why do programmers use loops?

Bugs: When Code Goes Wrong

A bug is a mistake in code that makes the computer do the wrong thing. The word comes from 1947, when a real moth got stuck inside a giant computer and made it break down! Today, bugs are mistakes in the instructions โ€” like a typo or a step in the wrong order. Finding and fixing bugs is called debugging. Real programmers spend lots of time debugging โ€” it is totally normal!

โ“

A robot is programmed to: (1) turn off the lights, (2) close the door. Instead, it closes the door first and then tries to turn off the lights in the dark. What type of mistake happened?

Want to keep learning?

Sign up for free to access the full curriculum โ€” all subjects, all ages.

Start Learning Free
Giving Computers Orders: Writing Your First Code Instructions | Free Sample | HYVE CARES | HYVE CARES