The next gate we are going to build is the OR gate. This gate receives two inputs and returns 1 if either one of the inputs is 1.

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

Here’s the truth table:

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



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

You can do this using traditional Python logic. Or, using a combination of the other gates you have learned about so far, you can make this in one line!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?