Exam-style question
Try this first
A system should accept a person when exactly one of `has_code` and `has_pass` is True. Write a Python 3 Boolean expression using XOR for this rule. Explain the result for each possible pair of input values: True/True, True/False, False/True and False/False.
Answer and explanation
Concise answer
The expression is `has_code ^ has_pass`.
Why this is correct
The caret operator `^` performs XOR on Boolean values in Python 3. The rule requires exactly one true input, which is the defining behaviour of XOR.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
