Comparison Operators
are used to write expressions that compare one value with another
The expressions always result in True or False
comparison expression sample:
print(“mint” == “strawberry”)
>False
Comparison operators
Equals == (100==100) Not equal != (100!=100) Less than < (100<100) Greater than > (100>100) Less than or equal <= (100<=100) Greater than or equal >= (100=>100)
Comparison Operators with if
my_name = "Brighticorn" your_name = "Grace Hopper"
if my_name == your_name:
print(“We have the same name!”)
else:
print(“You have a cool name.”)
> You have a cool name.
more samples
password = "love2code" input_password = "love_to_code"
if password != input_password:
print(“ACCESS DENIED”)
> ACCESS DENIED