Computers are capable of dizzying feats, but they’re built from humble origins. At the lowest level, computers run on electric currents limited to two states: power or no power.

There are many ways to represent the two states:

  • “I have current!” vs. “I don’t have current!”
  • “on” vs. “off”
  • + vs. -
  • True vs. False
  • 1 vs. 0

We’ll use 1 and 0 for the remainder of the lesson. This piece of information (power or no power) localized to a single location is called a bit.

  • Bit with power: 1
  • Bit without power: 0

Logic gates receive one or more inputs of current and alter the power according to their rules.

Some logic gates will only output power if both of their inputs are powered:

logic_gate(1, 1) # 1 logic_gate(0, 1) # 0 logic_gate(1, 0) # 0 logic_gate(0, 0) # 0

Other logic gates output power if either of the inputs are powered:

logic_gate(1, 1) # 1 logic_gate(0, 1) # 1 logic_gate(1, 0) # 1 logic_gate(0, 0) # 0


Click on the inputs to activate their current and see how power is routed through the collected logic gates.

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?