brooks.patricia64
brooks.patricia64 7d ago • 20 views

Python 'if' Statement Examples for Middle School

Hey there! 👋 Let's learn about 'if' statements in Python. They're super useful for making your programs do different things based on whether something is true or not. Think of it like a 'choose your own adventure' book, but for computers! 💻
💻 Computer Science & Technology
🪄

🚀 Can't Find Your Exact Topic?

Let our AI Worksheet Generator create custom study notes, online quizzes, and printable PDFs in seconds. 100% Free!

✨ Generate Custom Content

1 Answers

✅ Best Answer
User Avatar
Nietzsche_Z Jan 2, 2026

📚 What is an 'if' Statement?

In Python, an if statement lets you run certain code only when a condition is true. It's like asking a question and then doing something based on the answer.

📝 Quick Study Guide

  • 🔑 Condition: A statement that can be either True or False.
  • ⚙️ Syntax: if condition: followed by indented code.
  • 💡 Indentation: Python uses indentation (spaces) to know which code belongs inside the if statement.
  • else: Optional. Runs code if the if condition is False.
  • 🔗 elif: Short for "else if". Checks another condition if the first if was False.

🧪 Examples

Here are some simple examples:

  1. Example 1:
    age = 12
    if age >= 13:
     print("You are a teenager.")
    else:
     print("You are not a teenager.")
    
  2. Example 2:
    score = 75
    if score >= 90:
     print("Excellent!")
    elif score >= 70:
     print("Good job!")
    else:
     print("Keep practicing.")
    

🧠 Practice Quiz

  1. What keyword starts an 'if' statement in Python?
    1. start
    2. if
    3. condition
    4. then
  2. What symbol is used to check if two values are equal in an 'if' statement?
    1. =
    2. ==
    3. !=
    4. <>
  3. What happens if the condition in an 'if' statement is False?
    1. The code inside the 'if' statement runs.
    2. The code inside the 'else' statement runs (if there is one).
    3. The program crashes.
    4. Nothing happens.
  4. Which of the following is the correct way to write an 'if' statement?
    1. if condition then:
    2. if condition:
    3. if (condition)
    4. if condition
  5. What does 'elif' stand for?
    1. else if
    2. end if
    3. else ignore
    4. easy if
  6. What is the purpose of indentation in an 'if' statement?
    1. To make the code look pretty.
    2. To tell Python which code belongs to the 'if' statement.
    3. To confuse the programmer.
    4. It has no purpose.
  7. What will be the output of the following code?
    x = 5
    if x > 10:
     print("x is greater than 10")
    else:
     print("x is not greater than 10")
    
    1. x is greater than 10
    2. x is not greater than 10
    3. Error
    4. Nothing
Click to see Answers
  1. B
  2. B
  3. B
  4. B
  5. A
  6. B
  7. B

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀