Now, we are going to create what’s called an XOR gate, an exclusive or gate. This gate receives two inputs, a and b, and only returns a 1 if one of the inputs is 1, but not if both of the inputs are 1.

To build your XOR_gate(), you should use any combination of the gates you’ve already made: NAND_gate(), NOT_gate(), AND_gate(), and OR_gate().

Here’s the truth table:

a b output
0 0 0
0 1 1
1 0 1
1 1 0



Define XOR_gate() which takes two inputs, a and b, and returns the outputs specified in the truth table.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?