Elena' s AI Blog

Making Decisions: The Fork in the Road

05 Jan 2026 / 7 minutes to read

Elena Daehnhardt


Lesson 4 of 11 36%


TL;DR: Use `if` to check a condition. If it is true, the indented code runs. If not, it is skipped. This is how computers think.

Computers Need Rules

If statements create decision points in code

Life is full of choices. If it is raining, take an umbrella. If I am hungry, eat a cookie.

Computers can make these choices too, but we have to give them the rules. We use the magic word if.

The Decision Diamond:
      ┌─────────┐
      │ Is it   │
      │raining? │
      └────┬────┘
           │
     ┌─────┴─────┐
   Yes│          │No
     ↓           ↓
  ┌────┐      ┌─────┐
  │Umbrella│  │Sunglasses│
  └────┘      └─────┘

The if Statement

How computers make decisions using if/else

age = 10

if age > 7:
    print("You are old enough to play!")

The Anatomy of a Decision

  1. if: The keyword.
  2. age > 7: The check (The Question). Is age bigger than 7?
  3. :: The colon (Essential! Don’t forget it).
  4. Indentation: The next line is pushed in (indented with 4 spaces or 1 Tab).

Rule: The indented code only runs if the answer is YES (True).

If age was 5, the computer would say nothing.

🚀 Try This NOW!

Predict what will happen:

score = 100

if score > 50:
    print("You win!")
Click to check! It prints "You win!" because 100 is greater than 50!

The else Statement (Or Else!)

What if we want to say something when the answer is NO?

password = input("What is the secret password? ")

if password == "python":
    print("Access Granted. Welcome, Master.")
else:
    print("Access Denied! Run away!")

Note: We use == (two equals signs) to ask “Are these the same?”. One = is for assigning values.

Visual Flow:
Is password == "python"?
    │
    ├─ YES → Print "Access Granted"
    │
    └─ NO → Print "Access Denied"

Common Checks

  • a > b : Is a bigger than b?
  • a < b : Is a smaller than b?
  • a == b: Are they equal?
  • a != b: Are they NOT equal?
  • a >= b: Is a bigger than or equal to b?
  • a <= b: Is a smaller than or equal to b?

🎮 Real-World Connection

This is how Roblox knows if you’re allowed to enter a VIP area! It checks: if player_has_pass == True: then let them in, else block them. Every game, app, and website uses if statements!

The elif Statement (What if there are THREE choices?)

Sometimes you need more than just YES or NO:

score = 85

if score >= 90:
    print("Grade: A - Amazing!")
elif score >= 70:
    print("Grade: B - Good job!")
else:
    print("Grade: C - Keep trying!")

elif means “else if” - another check if the first one fails!

Try It Yourself: The Bouncer

Write a program that asks for the user’s age.

  • If they are 18 or older, say “You can drive a car.”
  • Else, say “Keep riding your bike.”
age = input("How old are you? ")
# Trick: Convert text to number using int()
age_number = int(age)

if age_number >= 18:
    print("Vroom vroom! 🚗")
else:
    print("Pedal pedal! 🚲")

Extra Challenge: The Weather Advisor

Make a program that asks what the weather is like:

  • If “sunny” → “Wear sunglasses!”
  • If “rainy” → “Take an umbrella!”
  • If “snowy” → “Build a snowman!”
  • Else → “Have a great day!”

Common Mistakes & Fixes

 Wrong: if age > 10
             print("Old enough")
Why it fails: Missing the : at the end!

 Right: if age > 10:
              print("Old enough")
Always add the colon!

 Wrong: if age = 10:
Why it fails: Single = is for assigning, not checking!

 Right: if age == 10:
Use == to check if equal

 Wrong: if age > 10:
         print("This")
             print("That")
Why it fails: Inconsistent indentation!

 Right: if age > 10:
              print("This")
              print("That")
Both lines need same indentation!

🔍 Bug Hunter Betty Says:

“If you see ‘IndentationError’, it means your spaces are wonky! Make sure all the code under the if is pushed in by exactly 4 spaces (or 1 Tab). Don’t mix spaces and tabs!”

🎉 Achievement Unlocked: Decision Maker! Wizard Level: Sorcerer (4/10 complete)

📝 Today’s Spell Book (Quick Reference)

if condition:        # If this is True
    do_something()   # Run this (indented!)
    
if condition:        # If this is True
    do_this()
else:                # Otherwise
    do_that()
    
if condition1:       # Check first condition
    option1()
elif condition2:     # If first fails, check this
    option2()
else:                # If all fail
    option3()

# Comparison operators:
# >  greater than
# <  less than
# == equal to
# != not equal to
# >= greater or equal
# <= less or equal

💡 Parent/Teacher Tip

If your learner is confused about == vs =, explain it like this: = is like putting something IN a box (assignment), while == is like asking “Are these boxes holding the same thing?” (comparison). You can’t ask a question with just one equals sign!

In the next lesson, we’ll learn how to make the computer repeat tasks over and over!


This post is part of the Python Basics for Kids series, based on “Python for Kids from 8 to 88”.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2026) 'Making Decisions: The Fork in the Road', daehnhardt.com, 05 January 2026. Available at: https://daehnhardt.com/courses/book0/04-making-decisions/
Course Library