Subscriber only lesson.
Sign up to this course to view this lesson.
About this lesson
How to compare two or more variables and test with logic (and, or, not).
Download this lesson’s related exercise files.Comparison and Logic Operators.docx
199.4 KB Comparison and Logic Operators - Solution.docx
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.
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.