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

Study for the CodeHS AP Computer Science Principles (CSP) Exam. Prepare with flashcards and multiple choice questions, each question comes with hints and explanations. Get ready for success!

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