Studyfin Studyfin ✨ Sign up free

Boolean logic (AND, OR, NOT)

Grade 6 · Coding · Free lesson

Hello! I am Studyfin, your coding buddy. Today, we will learn how computers make decisions using simple True and False rules!

In coding, we use Boolean expressions to represent data. A Boolean expression is just a statement that is either True or False. For example, 'It is raining' can be True or False.

xor

The AND operator joins two statements. For an AND expression to be True, BOTH statements must be True. If even one part is False, the whole thing becomes False.

TRUE Sun is out AND TRUE Warm day GO! Play outside

The OR operator is different. It only needs ONE statement to be True for the whole thing to be True. If you have a snack OR a drink, you are happy!

TRUE Have Cookie OR FALSE Have Juice TRUE Happy!

The NOT operator simply flips the value. It turns True into False, and False into True. It is like a light switch that changes the state to its opposite.

NOT
✏️ Worked example

Let's analyze this statement: (Light is Green) AND (Car has Gas). If the light is green (True) and the car has no gas (False), what is the final Boolean result?

  1. First, identify the two simple statements. Statement A is 'Light is Green'. Statement B is 'Car has Gas'.
  2. Next, find the Boolean value of each statement. Statement A is True. Statement B is False.
  3. Now, look at the operator connecting them. The operator is AND.
  4. Recall the rule for AND: both statements must be True to get a True output.
  5. Since one statement is False, the final Boolean expression represents False.
school
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons