Title: Logical Operations Slug: logical_operations
Summary: Logical Operations
Date: 2016-05-01 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

Create some simulated variables


In [1]:
x = 6

In [2]:
y = 9

In [3]:
z = 12

x or y


In [4]:
x or y


Out[4]:
6

x and y


In [5]:
x and y


Out[5]:
9

not x


In [6]:
not x


Out[6]:
False

x is equal to y


In [7]:
x == y


Out[7]:
False

x is not equal to y


In [8]:
x != y


Out[8]:
True

One is less than two


In [9]:
1 < 2


Out[9]:
True

Two is less than or equal to four


In [10]:
2 <= 4


Out[10]:
True

Three is equal to five


In [11]:
3 == 5


Out[11]:
False

Three is not equal to four


In [12]:
3 != 4


Out[12]:
True

x is less than y which is less than z


In [13]:
x < y < z


Out[13]:
True

x is less than y and y is less than z


In [14]:
x < y and y < z


Out[14]:
True