Computers & Coding
Exact steps, loops, if-then-else, variables, bits and checking facts online
Skills
- Clear, exact steps
- Loops and patterns
- If, then, else
- Variables — keeping score
- Events in games
- Debugging strategies
- Bits — 0s and 1s
- Keeping personal information private
- Is it true? Checking information online
Lessons
Clear, exact steps
A computer does exactly what you tell it, nothing more and nothing less. It can't guess what you mean, so every step in an algorithm must be clear and exact. Words like 'some', 'a little' or 'over there' confuse a computer. Examples: ❌ 'Walk forward' → how far? ✅ 'Walk forward 3 steps'; ❌ 'Put on the peanut butter' ✅ 'Open the jar, pick up the knife, spread peanut butter on one slice of bread'; 🤖 Robot game: if you forget 'turn left', the robot walks into the wall!. Tip: Test your steps by having a friend follow them exactly, without guessing.
Loops and patterns
When you spot a pattern of steps that repeats, you can use a loop. A loop runs the same steps a set number of times, or forever. Finding the part that repeats is the key to writing a good loop. Examples: 👏🦶👏🦶👏🦶 → repeat 3 times: clap, stomp; 🟦 Draw a square → repeat 4 times: move 50 steps, turn 90 degrees; 🔺 Draw a triangle → repeat 3 times: move 50 steps, turn 120 degrees. Tip: Circle the steps that repeat, then count how many times to set your loop.
If, then, else
An if-then-else conditional gives a program two paths. If the condition is true, the 'then' steps run. If it is false, the 'else' steps run instead, so the program always does one or the other. Examples: ☔ If it is raining, then wear a raincoat, else wear sunglasses; 🎮 If the player touches a coin, then add 1 to score, else keep moving; 🔢 If the number is even, then say 'Even!', else say 'Odd!'. Tip: Ask yourself: what should happen if the answer is yes, and what if it's no?
Variables — keeping score
A variable is like a labeled box that stores a value the program can use and change. Games use variables to keep track of things like score, lives and time. At the start of a game, the program sets the variable, then changes it as you play. Examples: 🏁 Start → set score to 0; 🪙 Collect 3 coins → change score by 1 each time → score = 3; ❤️ Lives start at 3 → bump into a monster → lives = 2. Tip: Give your variables clear names, like 'score' or 'lives', so you know what they hold.
Events in games
An event is something that happens, like a click or a key press, that tells code to start running. Games are full of events waiting for the player to do something. Each event is connected to the code it should run. Examples: 🟩 When green flag clicked → start the game; ⬆️ When up arrow key pressed → the character jumps; 🖱️ When the sprite is clicked → it says 'Ouch!'. Tip: Think of events as 'When this happens, do that!'
Debugging strategies
Debugging is finding and fixing mistakes in code. Good coders use strategies instead of guessing: they compare what should happen with what does happen, test small parts and change one thing at a time. After a fix, they test again to make sure it worked. Examples: 🔍 Step through the code one block at a time and watch what happens; 🧪 Change one thing, then run it again to see if the bug is gone; 🗣️ Explain your code out loud to a friend or a stuffed animal; you'll often spot the bug. Tip: Stay calm and curious, because every bug you fix makes you a better coder.
Bits — 0s and 1s
Computers store everything, like words, pictures and music, using bits. A bit is the smallest piece of information and can only be 0 (off) or 1 (on). In binary, each place is worth double the place to its right: 1, 2, 4, 8 and so on, and 8 bits make 1 byte. Examples: 💡 Light off = 0, light on = 1; 101 → 4 + 0 + 1 = 5; 110 → 4 + 2 + 0 = 6, and 111 → 4 + 2 + 1 = 7. Tip: Use 4 cards labeled 8, 4, 2, 1, flip some face up, and add them to read a binary number!
Keeping personal information private
Personal information is anything that tells who you are or where to find you: your full name, address, phone number, school, birthday, passwords and photos that show where you live. Never share it online or with strangers. If anyone asks for it, don't answer and tell a trusted adult. Examples: 🙊 A game chat asks 'What school do you go to?' → don't answer; tell a grown-up; 🦊 Use a made-up username like 'BlueFox' instead of your real name; 📸 Before posting a photo, check with a grown-up that it doesn't show your house number or school. Tip: When in doubt, leave it out, and ask a trusted adult first.
Is it true? Checking information online
Not everything online is true, because anyone can post anything. Be a detective: check who wrote it, whether it's recent and whether other trusted sources say the same thing. Photos and videos can be edited, too. Examples: 🦈 'Sharks can fly!' → sounds too wild → check a library book or encyclopedia; 📚 Find the same fact in 2 or 3 trusted sources before you believe it; 📢 A post says 'Click here to win!' → that's an ad or a trick; ask a grown-up. Tip: If something seems surprising or too good to be true, check it with a grown-up before you share it.