python equality code example
Example 1: python string equality
str = "hello"
print("hello" == "hello") # prints True
Example 2: python test for equality
0 == 0
#True
1 == 0
#False
0 = 0
1 = 0
#Error
Example 3: python is not
result is not None
Example 4: python comparison operators
# Below follow the comparison operators that can be used in python
# == Equal to
42 == 42 # Output: True
# != Not equal to
'dog' != 'cat' # Output: True
# < Less than
45 < 42 # Output: False
# > Greater Than
45 > 42 # Output: True
# <= Less than or Equal to
40 <= 40 # Output: True
# >= Greater than or Equal to
39 >= 40 # Output: False
Example 5: difference between = and is not python
In [1]: a = 3424
In [2]: b = 3424
In [3]: a is b
Out[3]: False
In [4]: a == b
Out[4]: True