Python for Kids Python If, Elif, and Else Statements

Learn to hack and code in Python!

Welcome to Learn to Hack and Code — where kids, teens, and adults can build their coding superpowers! In this post, we’ll explore a core Python skill every beginner should learn: if, elif, and else statements.

Whether you’re a student just starting out, a parent learning alongside your child, or an aspiring ethical hacker, this guide will help you understand how to make decisions with Python code.

learn to hack and code in python if else statements explained in easy to understand way
🧠 What Are If/Elif/Else Statements?

In Python, we use if/elif/else statements to tell our programs to make choices.

Think of it like this:

  • if something is true → do this
  • elif something else is true → do that instead
  • else → do this if none of the above are true

This is called conditional logic, and it’s the brain of every program!


🔍 Example:

pythonCopyEditage = 12

if age < 13:
    print("You're a kid!")
elif age < 18:
    print("You're a teen!")
else:
    print("You're an adult!")

Output:
You're a kid!

See how Python checks each condition in order? It runs the first one that is true.


 Why This Matters

Conditional logic is used in:

  • Games  (What happens when the player wins or loses?)
  • Websites  (Are you logged in? Are you a member?)
  • Cybersecurity tools  (Does the user have permission?)

So learning this early on gives you a huge head start!


 Watch the Tutorial with Mauro

Mauro is our awesome young instructor, and in this video, he breaks down if/elif/else in a fun and simple way. Kids and beginners love it!

👉 Watch below and follow along with your own code editor!


What You’ll Learn in the Video:

  • How to use if, elif, and else
  • Real-world logic examples
  • How indentation works in Python
  • Tips to avoid common beginner mistakes

Keep Learning with Us!

Explore more videos on Python, ethical hacking, HTML, and cybersecurity. Our mission is to help kids and families learn real-world tech skills that lead to exciting futures — all in a fun, hands-on way.

🔗 Visit: LearnToHackAndCode.com
🎬 Subscribe: YouTube Channel