Logical Operations

Want to learn more? I recommend these Python books: Python for Data Analysis, Python Data Science Handbook, and Introduction to Machine Learning with Python.

Create some simulated variables

x = 6
y = 9
z = 12

x or y

x or y
6

x and y

x and y
9

not x

not x
False

x is equal to y

x == y
False

x is not equal to y

x != y
True

One is less than two

1 < 2
True

Two is less than or equal to four

2 <= 4
True

Three is equal to five

3 == 5
False

Three is not equal to four

3 != 4
True

x is less than y which is less than z

x < y < z
True

x is less than y and y is less than z

x < y and y < z
True