Programming Fundamentals: Comparison Operators

Boolean expressions often involve comparison operators that can be evaluated to determine if they are True or False. Comparison operators include:
Different programming languages write these comparison operators in different ways:
LanguageEqualityGreater thanLess thanGreater than or equal toLess than or equal toInequality
Mathematics=><
“C” or C++==><>=<=!=
Pascal=><>=<=<>
SQL=><>=<=<>
Perl== or eq> or gt< or lt>= or ge<= or le!= or ne
Java==><>=<=!=
Basic=><>=<=!=
Python==><>=<=!=
Note for Perl language comparison of numbers uses the typical mathematical operators. Comparison of strings uses the eq, ge, le, gt, lt and ne operators.
Comparison operators are used to form expressions that can be evaluated as True or False. For example, we might ask if there are more than 30 students in the class using the following expression:
Number_of_Students > 30
If there are more than 30 students in the class, then this expression will evaluate to True. If there are 30 or fewer students in the class, then this expression will evaluate to False.
The following are more examples of these types of expressions:
QuestionExpression
Does Alice make more than $35,000 per year?Alice_Salary > 35000
Did the NY Giants defeat the Dallas Cowboys?Giants_Points > Cowboys_Points
Did anyone get a perfect score on the test?TestScore = 100
For each of these examples, supplying values for each of the expressions allows us to determine if that expression is True or False. For example, if Alice only makes $31,000, then the first expression would evaluate to False.