Which operator would you use to test if at least one of two conditions is true?

Prepare for the CodeHS AP Computer Science Principles Exam with multiple choice questions, detailed explanations, and helpful hints. Boost your confidence and get ready for your exam!

Multiple Choice

Which operator would you use to test if at least one of two conditions is true?

Explanation:
To test if at least one condition is true, use the OR operator. It evaluates to true whenever either condition is true (or both are true). For example, if you check whether someone is eligible with age > 18 OR has parental consent, the result is true if either condition holds. This is different from AND, which requires both conditions to be true, and from NOT, which negates a single condition. The symbol & is typically a bitwise AND in many languages, not the boolean OR you’re looking for. So the correct choice expresses that at least one condition being true should pass the test.

To test if at least one condition is true, use the OR operator. It evaluates to true whenever either condition is true (or both are true). For example, if you check whether someone is eligible with age > 18 OR has parental consent, the result is true if either condition holds. This is different from AND, which requires both conditions to be true, and from NOT, which negates a single condition. The symbol & is typically a bitwise AND in many languages, not the boolean OR you’re looking for. So the correct choice expresses that at least one condition being true should pass the test.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy