← Back to Week 1 Hub

Logical Operators: && || !

Workbook 1c, p.100 — Building compound conditions with AND, OR, and NOT

Operator Reference
&&
AND
Both sides must be true for the result to be true
🚪🚪 Two doors in a hallway — both must be open to walk through.
||
OR
At least one side must be true for the result to be true
🚪  🚪 Two separate exits — either one gets you out.
!
NOT
Flips true to false and false to true
💡 A light switch — flip it and the opposite happens.
Interactive Truth Tables — Toggle inputs and watch the result

&& (AND)

Both must be true

A
false
B
false
false && false
Result: false

|| (OR)

At least one must be true

A
false
B
false
false || false
Result: false

! (NOT)

Flips the value

A
false
!false
Result: true
Real-World Scenario — Ticket Pricing
30
false
false
Common Mistakes
Watch out for these:

Toggle the switches and move the slider to see how logical operators evaluate in real time.

← if/else Flowchart String Comparison →