Code viewer for World: Control Flow: Conditional ...
"""
Topic: Control Flow: Conditional Statements Using Logical Operators
Purpose: Learn how to combine multiple conditions using logical operators
Output: Shows how Python evaluates complex conditions
"""

# -----------------------------
# 1. Example variables
# -----------------------------
age = 25
has_id = True
is_member = False

# -----------------------------
# 2. Using the AND operator
# -----------------------------
# 'and' returns True only if all conditions are True
if age >= 18 and has_id:
    print("You are allowed to enter.")
else:
    print("Entry denied.")

# -----------------------------
# 3. Using the OR operator
# -----------------------------
# 'or' returns True if at least one condition is True
if is_member or age < 18:
    print("You get a discount.")
else:
    print("No discount available.")

# -----------------------------
# 4. Using the NOT operator
# -----------------------------
# 'not' reverses the condition
if not is_member:
    print("You are not a member.")
else:
    print("Welcome back, member!")

# -----------------------------
# 5. Combining multiple logical operators
# -----------------------------
score = 82
attendance = 90

if score >= 60 and attendance >= 75:
    print("You passed and meet all requirements.")
elif score >= 60 and attendance < 75:
    print("Passed, but attendance is too low.")
else:
    print("You did not pass.")

# -----------------------------
# 6. Notes
# -----------------------------
# 1. 'and', 'or', and 'not' are logical operators.
# 2. Logical operators combine multiple conditions.
# 3. Parentheses can improve readability in complex conditions.
# 4. Conditions are evaluated from left to right.
# 5. Logical operators help reduce deep nesting.