Home

Tutoring

Subjects

Live Classes

Study Coach

Essay Review

On-Demand Courses

Colleges

Games


Sign up

Log in

Opening subject page...

Loading your content

Practice

  • All Subjects
  • Algebra Flashcards
  • SAT Math Practice Tests
  • Math Question of the Day
  • Live Classes
  • On-Demand Courses

Varsity Tutors

  • Find a Tutor
  • Test Prep
  • Online Classes
  • K-12 Learning
  • College Search
  • VarsityTutors.com

© 2026 Varsity Tutors. All rights reserved.

← Back to quizzes

AP Computer Science Principles Quiz

AP Computer Science Principles Quiz: Boolean Expressions

Practice Boolean Expressions in AP Computer Science Principles with focused quiz questions that help you check what you know, review explanations, and build confidence with test-style prompts.

Question 1 / 20

0 of 20 answered

An online store gives free shipping if if (isMember OR purchaseOver100). In the given programming task, what is the result of the boolean expression when isMember is false and purchaseOver100 is true?

Select an answer to continue

What this quiz covers

This quiz focuses on Boolean Expressions, giving you a quick way to practice the rules, question types, and explanations that matter most for AP Computer Science Principles.

How to use this quiz

Try each quiz question before looking at the correct answer. Use the explanations to review missed ideas, then come back to similar questions until the pattern feels familiar.

All questions

Question 1

An online store gives free shipping if if (isMember OR purchaseOver100). In the given programming task, what is the result of the boolean expression when isMember is false and purchaseOver100 is true?

  1. False, because membership is required
  2. True, because one condition is true (correct answer)
  3. True, only if both conditions are true
  4. False, because OR behaves like AND

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating OR operations when conditions have mixed values. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (isMember OR purchaseOver100) determines free shipping eligibility through either membership or high purchase amount. Choice B is correct because with purchaseOver100 being true, the OR expression evaluates to true even though isMember is false, since OR requires only one true condition. Choice D is incorrect due to fundamental confusion between OR and AND operators, mistakenly treating OR as if it behaves like AND. To help students: Create comparison tables showing OR vs AND behavior with identical inputs. Practice with everyday examples like 'free entry with membership OR student ID' to reinforce the inclusive nature of OR.

Question 2

An access control algorithm unlocks a door only if if (userIsAdmin AND withinBusinessHours). Based on the algorithm described, what is the result of the boolean expression when withinBusinessHours is false?

  1. True, because admin overrides time
  2. False, even if userIsAdmin is true (correct answer)
  3. True, if userIsAdmin OR withinBusinessHours
  4. False, only when userIsAdmin is false

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations when one condition is false. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (userIsAdmin AND withinBusinessHours) determines whether a door unlocks when both conditions must be met. Choice B is correct because when withinBusinessHours is false, the entire AND expression evaluates to false regardless of userIsAdmin's value, since AND requires both conditions to be true. Choice A is incorrect due to misunderstanding operator precedence, falsely assuming admin status can override the AND logic. To help students: Create truth tables showing all possible combinations of the two variables. Emphasize that AND expressions are only true when ALL conditions are true, using real-world analogies like needing both a key AND the correct code to open a safe.

Question 3

A weather alert system issues an alert if (tempBelowFreezing AND precipitationLikely). Based on the algorithm described, which condition must be true for an alert?

  1. tempBelowFreezing is true and precipitationLikely is true (correct answer)
  2. tempBelowFreezing is true or precipitationLikely is true
  3. tempBelowFreezing is false and precipitationLikely is true
  4. Either condition is false to be safe

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations for safety-critical systems. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like weather alerts. In this scenario, the boolean expression (tempBelowFreezing AND precipitationLikely) determines when to issue a weather alert based on temperature and precipitation conditions. Choice A is correct because AND operations require both conditions to be true - the system only alerts when it's both below freezing AND precipitation is likely, indicating potential ice or snow hazards. Choice B is incorrect due to confusing AND with OR logic, which would create too many false alerts. To help students: Use real-world safety examples where multiple conditions must align, like 'alert only when cold AND wet.' Draw Venn diagrams showing the intersection where both conditions overlap.

Question 4

An online store applies a premium discount if if (isMember AND purchaseOver50). In the given programming task, which condition must be true for a premium discount to occur in this algorithm?

  1. isMember is true and purchaseOver50 is true (correct answer)
  2. isMember is true or purchaseOver50 is true
  3. isMember is false and purchaseOver50 is true
  4. isMember is true and purchaseOver50 is false

Explanation: This question tests understanding of boolean expressions in programming, specifically identifying when AND operations evaluate to true. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (isMember AND purchaseOver50) determines when a premium discount is applied, requiring both membership and minimum purchase amount. Choice A is correct because AND operations require both conditions to be true simultaneously for the entire expression to evaluate to true. Choice B is incorrect due to confusing AND with OR logic, mistakenly thinking only one condition needs to be true. To help students: Use Venn diagrams to visualize AND as the intersection of two sets. Practice with real-world scenarios where multiple requirements must all be met, like needing both a ticket AND valid ID to board a plane.

Question 5

An access control algorithm unlocks a door only if (userIsAdmin AND withinBusinessHours). Based on the algorithm described, what is the result of the boolean expression when userIsAdmin is true and withinBusinessHours is false?

  1. True, because admin overrides hours
  2. False, because both must be true (correct answer)
  3. True, because one condition is true
  4. False, because it is not a weekend

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations with mixed true/false conditions. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like access control. In this scenario, the boolean expression (userIsAdmin AND withinBusinessHours) determines whether a door unlocks when both conditions about user privileges and timing are evaluated. Choice B is correct because it accurately reflects that AND operations require both conditions to be true for the overall expression to be true - since withinBusinessHours is false, the entire expression evaluates to false. Choice C is incorrect due to confusing AND with OR logic, a common error where students think one true condition is sufficient for an AND expression. To help students: Use truth tables to visualize AND operations, showing that T AND F = F. Practice with real-world scenarios like 'you need both a ticket AND valid ID to enter' to reinforce that both conditions must be met.

Question 6

An email filter auto-archives if (NOT fromTrustedSender AND hasSpamKeywords). Based on the algorithm described, which condition must be true for archiving?

  1. Sender is trusted and keywords appear
  2. Sender is not trusted and keywords appear (correct answer)
  3. Sender is not trusted or keywords appear
  4. Sender is trusted or keywords do not appear

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations with NOT operators in spam filtering. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like email archiving. In this scenario, the boolean expression (NOT fromTrustedSender AND hasSpamKeywords) determines when to auto-archive emails based on sender trust and content. Choice B is correct because it accurately describes both required conditions: the sender must not be trusted (NOT fromTrustedSender = true) AND spam keywords must be present - only emails that are both untrusted and spammy get archived. Choice C is incorrect due to confusing AND with OR logic, which would archive too many legitimate emails. To help students: Break down compound conditions into parts, evaluating NOT first. Use examples like 'archive if untrusted AND suspicious' to reinforce that both red flags must be present.

Question 7

In an access control system, a badge opens a lab door only when if (userIsAdmin AND withinBusinessHours) is true; otherwise it logs a denied attempt. Based on the algorithm described, which condition must be true for access to occur in this algorithm?

  1. userIsAdmin is true OR withinBusinessHours is true
  2. userIsAdmin is true AND withinBusinessHours is true (correct answer)
  3. userIsAdmin is true, regardless of withinBusinessHours
  4. withinBusinessHours is true, regardless of userIsAdmin

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations for access control logic. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like granting or denying access. In this scenario, the boolean expression (userIsAdmin AND withinBusinessHours) determines whether the lab door opens, requiring both conditions to be simultaneously true. Choice B is correct because it accurately reflects the logic of the AND operator, which requires both userIsAdmin and withinBusinessHours to be true for the entire expression to evaluate to true. Choice A is incorrect due to confusing AND with OR logic, a common error where students assume only one condition needs to be met. To help students: Use truth tables to visualize how AND operations require all conditions to be true, unlike OR operations. Practice with real-world scenarios like security systems where multiple conditions must be satisfied for access.

Question 8

A weather alert system sends a push notification when if (tempBelowFreezing AND precipitationLikely) is true; otherwise it posts a normal forecast. Based on the algorithm described, which condition must be true for an alert to occur in this algorithm?

  1. tempBelowFreezing is true OR precipitationLikely is true
  2. tempBelowFreezing is false AND precipitationLikely is true
  3. tempBelowFreezing is true AND precipitationLikely is true (correct answer)
  4. precipitationLikely is true, regardless of temperature

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations for weather alert systems. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like sending notifications. In this scenario, the boolean expression (tempBelowFreezing AND precipitationLikely) determines whether a push notification is sent for potentially icy conditions. Choice C is correct because it accurately reflects the logic of the AND operator, requiring both temperature below freezing and likely precipitation to trigger an alert. Choice A is incorrect due to confusing AND with OR logic, assuming either condition alone could trigger the alert. To help students: Use real-world examples where multiple conditions create a specific hazard (ice requires both cold and moisture). Practice identifying when AND logic is appropriate versus OR logic based on the problem context.

Question 9

An access control system logs an alert if if (NOT userIsAdmin AND accessAfterHours). Based on the algorithm described, what is the result of the boolean expression when userIsAdmin is true?

  1. True, if accessAfterHours is true
  2. False, because NOT userIsAdmin is false (correct answer)
  3. True, because admin implies after-hours access
  4. False, only if accessAfterHours is false

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating expressions with NOT operators applied to the first condition. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (NOT userIsAdmin AND accessAfterHours) determines when to log an alert for non-admin after-hours access. Choice B is correct because when userIsAdmin is true, NOT userIsAdmin evaluates to false, making the entire AND expression false regardless of accessAfterHours value. Choice A is incorrect due to ignoring the NOT operator's effect, failing to recognize that admin users never trigger alerts in this system. To help students: Practice evaluating NOT operators as the first step before considering AND/OR operations. Use truth tables to systematically work through all possible combinations of boolean values.

Question 10

An access control algorithm unlocks a door if if (userIsAdmin AND withinBusinessHours). Based on the algorithm described, how would changing AND to OR impact the outcome?

  1. Unlocks only when both conditions are true
  2. Unlocks when either condition is true (correct answer)
  3. Unlocks only when both conditions are false
  4. Unlocks only when withinBusinessHours is false

Explanation: This question tests understanding of boolean expressions in programming, specifically comparing the behavioral differences between AND and OR operators. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, changing the boolean expression from (userIsAdmin AND withinBusinessHours) to (userIsAdmin OR withinBusinessHours) fundamentally alters when the door unlocks. Choice B is correct because OR makes the door unlock when either condition is true, creating a more permissive access policy compared to AND which requires both. Choice A is incorrect due to describing the original AND behavior rather than recognizing how OR changes the logic. To help students: Create side-by-side truth tables comparing AND vs OR with the same inputs. Use security scenarios to illustrate how OR creates more access points while AND creates stricter requirements.

Question 11

An email filter flags priority mail if if (senderIsTrusted AND hasUrgentKeyword). Based on the algorithm described, how does the boolean expression affect the algorithm when senderIsTrusted is false?

  1. It still flags priority if hasUrgentKeyword is true
  2. It never flags priority, regardless of hasUrgentKeyword (correct answer)
  3. It flags priority only when hasUrgentKeyword is false
  4. It flags priority if senderIsTrusted OR hasUrgentKeyword

Explanation: This question tests understanding of boolean expressions in programming, specifically how AND operations fail when one required condition is false. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (senderIsTrusted AND hasUrgentKeyword) determines when email is flagged as priority, requiring both trusted sender and urgent keywords. Choice B is correct because when senderIsTrusted is false, the entire AND expression always evaluates to false, preventing any priority flagging regardless of hasUrgentKeyword's value. Choice A is incorrect due to misunderstanding AND logic, falsely believing one true condition can compensate for a false condition. To help students: Emphasize that AND is an 'all or nothing' operation where any false condition makes the entire expression false. Use circuit diagrams where all switches must be closed for current to flow.

Question 12

A weather alert algorithm sends a heat warning if if (tempHigh AND NOT precipitationExpected). In the given programming task, which condition must be true for a heat warning to occur in this algorithm?

  1. tempHigh is true and precipitationExpected is false (correct answer)
  2. tempHigh is true and precipitationExpected is true
  3. tempHigh is false and precipitationExpected is false
  4. tempHigh is true or precipitationExpected is false

Explanation: This question tests understanding of boolean expressions in programming, specifically combining AND with NOT operators to create complex conditions. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (tempHigh AND NOT precipitationExpected) determines when a heat warning is sent, requiring high temperature without expected precipitation. Choice A is correct because it accurately reflects that tempHigh must be true AND precipitationExpected must be false (making NOT precipitationExpected true) for the entire expression to evaluate to true. Choice B is incorrect due to misunderstanding the NOT operator, failing to recognize that precipitationExpected must be false, not true. To help students: Practice evaluating NOT operators first before combining with AND/OR operations. Use parentheses to clarify order of operations and create step-by-step evaluations showing how NOT flips the boolean value.

Question 13

An email filter moves messages to spam if if (hasSpamKeywords OR NOT senderIsTrusted). Based on the algorithm described, what is the result of the boolean expression when senderIsTrusted is false?

  1. False, because spam keywords must appear
  2. True, because NOT senderIsTrusted is true (correct answer)
  3. True, only if hasSpamKeywords is false
  4. False, because OR requires both conditions

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating OR operations with NOT operators. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches. In this scenario, the boolean expression (hasSpamKeywords OR NOT senderIsTrusted) determines when an email is moved to spam, triggering if either condition is met. Choice B is correct because when senderIsTrusted is false, NOT senderIsTrusted evaluates to true, making the entire OR expression true regardless of hasSpamKeywords value. Choice D is incorrect due to fundamental misunderstanding of OR logic, falsely believing OR requires both conditions to be true when it actually requires only one. To help students: Emphasize that OR expressions are true when AT LEAST ONE condition is true. Create flowcharts showing different paths that lead to a true result in OR expressions.

Question 14

An email filter flags spam when if (hasSpamKeywords OR NOT fromTrustedSender). Based on the algorithm described, which condition must be true for an email to be flagged?

  1. Only fromTrustedSender is true
  2. hasSpamKeywords is true, and sender is trusted
  3. hasSpamKeywords is true OR sender is not trusted (correct answer)
  4. Subject contains no keywords and sender is trusted

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating OR operations combined with NOT operators. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like spam filtering. In this scenario, the boolean expression (hasSpamKeywords OR NOT fromTrustedSender) determines when an email gets flagged as spam based on content or sender trust status. Choice C is correct because it accurately captures that OR operations require at least one condition to be true - either the email has spam keywords OR the sender is not trusted (NOT fromTrustedSender = true). Choice A is incorrect due to misunderstanding OR logic by thinking both conditions must be evaluated separately. To help students: Create truth tables for compound expressions with OR and NOT. Use concrete examples like 'flag if suspicious content OR unknown sender' to show how either condition triggers the action.

Question 15

A store shows free shipping if (isMember OR purchaseOver50). Based on the algorithm described, what is the result when both are false?

  1. True, because OR needs one false
  2. False, because neither condition is true (correct answer)
  3. True, because NOT isMember is assumed
  4. False, only if purchaseOver50 is true

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating OR operations when both conditions are false. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like shipping eligibility. In this scenario, the boolean expression (isMember OR purchaseOver50) determines whether free shipping is offered based on membership status or purchase amount. Choice B is correct because OR operations only return false when both conditions are false - since neither membership nor minimum purchase requirements are met, no free shipping is shown. Choice A is incorrect due to misunderstanding OR logic, thinking it needs one false condition rather than at least one true condition. To help students: Use truth tables emphasizing that OR only fails when everything is false. Practice with examples like 'qualify if member OR big spender' to show both paths to qualification.

Question 16

An online store applies a discount only if (isMember AND purchaseOver50). Based on the algorithm described, what is the result when isMember is false?

  1. True, if purchaseOver50 is true
  2. False, regardless of purchase amount (correct answer)
  3. True, because NOT isMember is implied
  4. False, only when purchaseOver50 is false

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations when one condition is definitively false. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like discount eligibility. In this scenario, the boolean expression (isMember AND purchaseOver50) determines whether a discount applies based on membership status and purchase amount. Choice B is correct because when using AND logic, if any condition is false, the entire expression is false regardless of other conditions - since isMember is false, the discount never applies no matter the purchase amount. Choice A is incorrect due to overlooking that AND requires all conditions to be true, not just one. To help students: Emphasize the 'all or nothing' nature of AND operations using examples like 'need membership AND minimum purchase.' Practice evaluating expressions by checking each condition systematically.

Question 17

A weather app sends a rain notice if (precipitationLikely OR highHumidity). Based on the algorithm described, what is the result when precipitationLikely is true?

  1. False, unless highHumidity is also true
  2. True, regardless of highHumidity (correct answer)
  3. False, because OR requires both true
  4. True, only during business hours

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating OR operations when one condition is already true. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like weather notifications. In this scenario, the boolean expression (precipitationLikely OR highHumidity) determines when to send a rain notice based on direct precipitation likelihood or atmospheric conditions. Choice B is correct because OR operations return true when at least one condition is true - since precipitationLikely is true, the expression is true regardless of the highHumidity value. Choice A is incorrect due to overthinking OR logic and adding unnecessary dependencies between conditions. To help students: Emphasize that OR short-circuits when finding a true condition. Use examples like 'notify if rain likely OR conditions suggest rain' to show redundant safety in notifications.

Question 18

A store applies a bonus coupon if (isMember AND purchaseOver100). Based on the algorithm described, what is the result when purchaseOver100 is false?

  1. True, if isMember is true
  2. False, because both must be true (correct answer)
  3. True, because AND acts like OR
  4. False, only if isMember is false

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating AND operations when one required condition is false. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like coupon eligibility. In this scenario, the boolean expression (isMember AND purchaseOver100) determines whether a bonus coupon applies based on membership and purchase threshold. Choice B is correct because AND operations require both conditions to be true - since purchaseOver100 is false, the entire expression is false regardless of membership status, so no bonus coupon is applied. Choice A is incorrect due to focusing on only one condition while ignoring that AND requires both to be satisfied. To help students: Use truth tables showing that F AND T = F and F AND F = F. Practice with real scenarios like 'bonus requires membership AND big purchase' to reinforce the all-or-nothing nature of AND.

Question 19

An email filter moves messages to Spam when if (hasSpamKeywords OR NOT fromTrustedSender) is true; otherwise it delivers to Inbox. Based on the algorithm described, what is the result of the boolean expression when hasSpamKeywords is false and fromTrustedSender is true?

  1. True, because trusted senders trigger Spam checks
  2. False, because neither condition makes the expression true (correct answer)
  3. True, because NOT fromTrustedSender becomes true
  4. False, because OR requires both conditions to be false

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating compound expressions with OR and NOT operators. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like email filtering. In this scenario, the boolean expression (hasSpamKeywords OR NOT fromTrustedSender) determines whether an email goes to Spam, with hasSpamKeywords=false and fromTrustedSender=true. Choice B is correct because when hasSpamKeywords is false and fromTrustedSender is true, NOT fromTrustedSender becomes false, making the entire OR expression false (false OR false = false). Choice C is incorrect due to misunderstanding the NOT operator, thinking it makes the entire expression true rather than just negating fromTrustedSender. To help students: Break down compound expressions step-by-step, evaluating NOT operations first before combining with OR/AND. Use parentheses to clarify order of operations and practice substituting actual values into expressions.

Question 20

An access control system unlocks a server room when if (hasBadge AND NOT isOnDenyList) is true; otherwise it sounds a buzzer. Based on the algorithm described, what is the result of the boolean expression when hasBadge is true and isOnDenyList is true?

  1. True, because a badge always unlocks the door
  2. False, because NOT isOnDenyList becomes false (correct answer)
  3. True, because NOT applies to hasBadge instead
  4. False, because AND becomes false when hasBadge is true

Explanation: This question tests understanding of boolean expressions in programming, specifically evaluating expressions with AND and NOT operators in security systems. Boolean expressions evaluate to true or false based on the logic of conditions set within an algorithm, often controlling decision branches like access control. In this scenario, the boolean expression (hasBadge AND NOT isOnDenyList) determines server room access, with hasBadge=true and isOnDenyList=true. Choice B is correct because when isOnDenyList is true, NOT isOnDenyList becomes false, making the entire AND expression false (true AND false = false), thus denying access. Choice A is incorrect due to ignoring the deny list check, assuming a badge alone grants access regardless of security restrictions. To help students: Work through NOT operations first before evaluating the full expression. Explain that deny lists act as overrides that block access even with valid credentials.