Exam Impact: Boolean expressions appear in every conditional and loop -- they underpin the majority of BI3 MCQ questions.
💡 Why This Matters
Can you take out a library book? Rule: you must have a library card AND NOT have overdue fines. That's a boolean expression. Programming conditions work exactly the same way.
Relational and Logical Operators
Boolean expressions combine relational operators (comparing values) with logical operators (combining conditions). They evaluate to true or false.
x = 7
print(x > 5) # True
print(x == 10) # False
print(x > 5 and x < 10) # True
print(x < 5 or x > 6) # True
print(not x == 7) # False
x <- 7
DISPLAY(x > 5) {true}
DISPLAY(x = 10) {false}
DISPLAY(x>5 AND x<10) {true}
DISPLAY(x<5 OR x>6) {true}
DISPLAY(NOT(x = 7)) {false}
Truth Table Rules
AND: true only when BOTH sides are true. OR: true when AT LEAST ONE side is true. NOT: flips the value.
Exam trap: OR is inclusive. true OR true = true. Students sometimes assume it means “either/or but not both.” It doesn’t.
Practice Problems
🔎 Practice MCQ
What is the value of (3 > 5) OR (10 > 7)?
⚠️ Predict your answer BEFORE clicking.
🔎 Practice MCQ
Which expressions are FALSE when score = 72? I. score >= 70 AND score <= 80 II. score > 80 OR score < 60 III. NOT(score == 72)
⚠️ Predict your answer BEFORE clicking.
🔎 Practice MCQ
A gate opens if a person is a member OR holds a day pass, AND is NOT banned. Correct expression?
⚠️ Predict your answer BEFORE clicking.
🎮 Game
Boolean Evaluator
Evaluate each boolean expression to true or false. 8 questions.
0
Correct
1/8
Question
0
Streak 🔥
🤔 Evaluate:
0/8
correct
💻 Python Code Editor
Practice Problems
Write Python and check your answer. Paste into Replit for complex programs.
Problem 1 of 3
Print True if x=15 is between 10 and 20 inclusive. Expected: True
Hint: print(x >= 10 and x <= 20)
Problem 2 of 3
Print True if n=7 is NOT equal to 0. Expected: True
Hint: print(n != 0)
Problem 3 of 3
Spot the error: should print True when score>=60 OR grade=='pass'. score=55, grade='pass'. print(score >= 60 and grade == 'pass')
Hint: Change 'and' to 'or'. With OR, either condition being true makes the whole expression true.
Frequently Asked Questions
In everyday English 'or' often means exclusive-or (one or the other, not both). In computer science OR is inclusive: true if at least one side is true, including when both are true.
NOT binds tightest, then AND, then OR -- similar to multiplication before addition. Use parentheses to make compound expressions unambiguous.
Yes. done = False, then done = True when a task completes. Check with if done: later. Common in loops and state flags.
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed.
Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Typically responds within 24 hours
✓
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.