Locked lesson.
About this lesson
How to compare two or more variables and test with logic (and, or, not).
Exercise files
Download this lesson’s related exercise files.
Comparison and Logic Operators.docx58.8 KB Comparison and Logic Operators - Solution.docx
58.8 KB
Quick reference
Comparison and Logic Operators
Comparison operators are used to compare, logic operators are used for logic.
When to use
Anytime you want to compare more than one thing, use comparison operators. Logic operators are used to do basic logic.
Instructions
The main comparison operators are:
== // equal to
!= // not equal to
> // greater than
>= // greater than or equal to
< // less than
<= // less than or equal to
The main logic operators are
&& // and
|| // or
Hints & tips
- Use comparison operators to compare things
- remember == is equal to (not =)
Lesson notes are only available for subscribers.