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?
Opening subject page...
Loading your content
AP Computer Science Principles Quiz
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?
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.
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.
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?
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.
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?
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.
A weather alert system issues an alert if (tempBelowFreezing AND precipitationLikely). Based on the algorithm described, which condition must be true for an alert?
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.
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?
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.
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?
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.
An email filter auto-archives if (NOT fromTrustedSender AND hasSpamKeywords). Based on the algorithm described, which condition must be true for archiving?
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.
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?
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.
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?
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.
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?
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.
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?
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.
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?
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.
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?
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.
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?
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.
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?
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.
A store shows free shipping if (isMember OR purchaseOver50). Based on the algorithm described, what is the result when both are false?
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.
An online store applies a discount only if (isMember AND purchaseOver50). Based on the algorithm described, what is the result when isMember 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.
A weather app sends a rain notice if (precipitationLikely OR highHumidity). Based on the algorithm described, what is the result when precipitationLikely is true?
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.
A store applies a bonus coupon if (isMember AND purchaseOver100). Based on the algorithm described, what is the result when purchaseOver100 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.
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?
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.
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?
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.