Introduction to Programming

AND, OR, and NOT Operators

Lesson 7: Logical Operators

What are Logical Operators?

Sometimes a single condition is not enough to make a decision. What if you want to check two conditions at once? Or what if you want to do something only when a condition is NOT true? That's where logical operators come in!

Logical operators combine or modify Boolean (true/false) values to create more complex conditions. PictoBlox supports three logical operators: AND, OR, and NOT.
PictoBlox Operators palette showing AND, OR, and NOT operator blocks

The AND Operator

The AND operator returns true only when both conditions are true. If either condition is false, the result is false.

AND Truth Table

Condition ACondition BA AND B
truetruetrue
truefalsefalse
falsetruefalse
falsefalsefalse

The OR Operator

The OR operator returns true when at least one of the conditions is true. It only returns false when both conditions are false.

OR Truth Table

Condition ACondition BA OR B
truetruetrue
truefalsetrue
falsetruetrue
falsefalsefalse

The NOT Operator

The NOT operator flips a Boolean value. If the condition is true, NOT makes it false. If it is false, NOT makes it true.

NOT Truth Table

Condition ANOT A
truefalse
falsetrue

Real-World Analogies

Logical Operators in Real Life

OperatorReal-Life Example
ANDI will go to the park if it is sunny AND I have finished my homework.
ORI will have juice OR water with my lunch.
NOTI will go outside if it is NOT raining.
Block coding example showing an If block with an AND condition combining two relational operator blocks

Subscribe to our newsletter.

Get updates to news and events.