Putting the Pieces Together
See how variables, sequence, decisions, and loops combine into one small, understandable program.
You've learned the four core building blocks separately. Real programs combine them. Let's read one small program that uses all four — slowly, like detectives.
A tiny guessing-game checker
Imagine a game where the secret number is 7, and we check three guesses someone made:
secret = 7
guesses = [4, 7, 9]
for each guess in guesses:
if guess == secret:
show "Correct! You found it."
else:
show "Nope, keep trying."Let's read it line by line
secret = 7— a variable stores the secret number.guesses = [4, 7, 9]— another variable stores a list of three guesses.- The loop (
for each guess) runs once per guess, in sequence. - Inside the loop, the decision (
if) checks whether the current guess equals the secret. - Depending on the answer, it shows one message or the other.
What does it display?
Let's play computer and walk through each loop pass:
- guess is 4 → 4 == 7? No → show "Nope, keep trying."
- guess is 7 → 7 == 7? Yes → show "Correct! You found it."
- guess is 9 → 9 == 7? No → show "Nope, keep trying."
So the output is:
Nope, keep trying.
Correct! You found it.
Nope, keep trying.That's a real program's skeleton
Notice that this tiny example has the shape of countless real programs: store some data, loop over it, make a decision each time, and produce output. The four building blocks aren't just theory — they genuinely combine to do useful work.
Tip: If reading that program felt a little slow or effortful — that's completely normal and actually a good sign. You were doing real programming thinking: tracking variables and tracing the flow. It gets faster with practice. Promise.
In the next two lessons, you'll stop reading pretend code and run real code yourself. Get ready!
Quick check
Q1 In the guessing-game example, which building block decides whether to print 'Correct!' or 'Nope'?
Q2 What is the loop in that example responsible for?
Want to save your progress? It's free.
Create a free account