Our next gate is the AND gate. This gate receives two inputs and only returns current if the inputs are both on.

As in previous exercises, you’ll only be able to use gates you’ve previously built: NAND_gate(), and NOT_gate().

Here’s the truth table:

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



Define AND_gate() which has two parameters a and b.

AND_gate() should return 1 if both a and b are 1. It should return 0 otherwise.

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?