Code viewer for World: Control Flow: Conditional ...
"""
Topic: Control Flow: Conditional Statements (if, elif, else)
Purpose: Learn how to make decisions in Python using conditions
Output: Shows how Python executes different blocks of code based on conditions
"""

# -----------------------------
# 1. Example variable
# -----------------------------
age = 20

# -----------------------------
# 2. Using if statement
# -----------------------------
# The 'if' block runs only if the condition is True
if age >= 18:
    print("You are an adult.")

# -----------------------------
# 3. Using if-else statement
# -----------------------------
# 'else' runs when the if condition is False
if age >= 21:
    print("You can legally drink.")
else:
    print("You are not allowed to drink yet.")

# -----------------------------
# 4. Using if-elif-else statement
# -----------------------------
# 'elif' is used to check multiple conditions
score = 85

if score >= 90:
    print("Grade: A")
elif score >= 75:
    print("Grade: B")
elif score >= 60:
    print("Grade: C")
else:
    print("Grade: F")

# -----------------------------
# 5. Using comparison operators
# -----------------------------
# ==, !=, >, <, >=, <= are commonly used in conditions
temperature = 30

if temperature > 35:
    print("It's very hot.")
elif temperature > 25:
    print("It's warm.")
else:
    print("It's cool.")

# -----------------------------
# 6. Notes
# -----------------------------
# 1. Python uses indentation (not braces) to define code blocks.
# 2. Conditions must evaluate to True or False.
# 3. 'elif' can be used multiple times.
# 4. Only one block in an if-elif-else chain runs.
# 5. Conditions often use comparison and logical operators.