Comparison Operators in Python
Comparison Operators:
Equals ==
Dees not equal !=
Less than <
Greater than >
Less than or equals <=
Greater than or equals >=
Examples:
1==1
True
1!=1
False
1<2
True
1>2
False
1<=1
True
1>=1
True
True
1!=1
False
1<2
True
1>2
False
1<=1
True
1>=1
True
Logical Operators to combine the comparisons:
and : Both condition should be true to TRUE
or
not : Either of the condition to be true to TRUE
Examples:
1==1 and 2==2
True
1==2 and 2==2
False
1==1 or 2==2
True
1==2 or 2==2
True
True
1==2 and 2==2
False
1==1 or 2==2
True
1==2 or 2==2
True
Comments
Post a Comment