The Logic of Code
Discover how computers make decisions with variables, conditions, loops, and functions
Discover how computers make decisions with variables, conditions, loops, and functions
A variable is like a labeled box that stores information
Variables let programs remember information. A game tracks your score, a website remembers your username, and an app saves your preferences - all using variables!
Computers use IF-THEN-ELSE to choose what to do
Every login form uses conditionals: IF password is correct THEN let user in, ELSE show error message. Video games use thousands of these decisions every second!
Why write the same code 100 times when you can loop once?
Drawing 60 frames per second in a game? Loop. Processing 1000 emails? Loop. Checking every pixel in an image? Loop. Computers are really just very fast loopers!
Write code once, use it anywhere - like a recipe card
Instead of writing damage calculation code every time an attack happens, you write it ONCE as a function. Game has 50 attack types? Just call calculateDamage() 50 different ways!
The building blocks of all computer decisions
Your computer's CPU contains billions of tiny logic gates making AND, OR, NOT decisions. Every calculation, every game frame, every click - it's all gates working together at lightning speed!
Drag nodes to create a simple program flowchart
Professional programmers often sketch flowcharts before writing code. It helps you see the logic clearly and catch problems early. Planning saves time!
Now you understand the building blocks that power every program, game, and app.
Named boxes that store data - numbers, text, true/false
IF-THEN-ELSE lets programs make decisions
Repeat code without rewriting it - computers are fast loopers!
Reusable code recipes - write once, use everywhere
Put your new knowledge into practice!