LESSON #3
LOGICAL OPERATORS
Python Logical Operators
and
or
not
AND
OR
AND
OR
AND
NOT
NOT
AND
=
or
=
COMPARISONS
COMPARISONS
== Equals
!= Does not equal
>= Greater than or equal to
> Greater than
<= Less than or equal to
< Less than
What is the difference between the == and = operators in Python?
Difference between == and =
x = 5
y = 5
print(x==y) # This would print True!
x = 5
It is important to note that using = instead of == in a comparison statement can result in unintended consequences or errors.
#COMPARISONS
>>> print(2 != 2)
>>> print(4 >= 2)
>>> print(“Hi” == “Hello”)
>>> print(10 < 11)
False
True
False
True
Now Let’s Add
Logical Operators!
#COMPARISONS
x = 5
>>> print(x > 3 and x < 10)
>>> print(x > 3 or x < 4)
>>> print(x >= 7 and x < 3)
>>> print(x <= 3 or x >= 5)
True
True
False
True
Google Slides
Activity!