Loading section...
Comparison Operators
Programs need to make decisions. Should this user be granted access? Is the account balance sufficient? Has the deadline passed? These are all yes-or-no questions, and comparison operators let you ask them. What is a Comparison? Six Comparison Operators Python has six comparison operators. Each one asks a different type of question: Checking if two values are exactly the same: Greater-than and less-than operators compare which side is larger or smaller: Comparing Strings You can compare strings too. Python compares them alphabetically, character by character. This is called lexicographic ordering: All three are True. "apple" comes before "banana" alphabetically. String comparison is case-sensitive: First is False (different case). Second is True (uppercase has lower character code than low