Python Operators Flashcards
Python Order of Operations
PEMDAS
Parentheses Exponents Multiplication Division Addition Subtraction
Addition
+
5 + 2 = 7
Subtraction
-
5 - 2 = 3
Multiplication
*
2 * 3 = 6
Division
/
6 / 3 = 2
Modular division (Remainder)
%
5 % 2 = 1
Exponential
**
5 ** 2 = 25
Floor division
//
5 // 2 = 2
The assignment operator
=
Add and reassign.
+=
Subtract and reassign.
-=
Multiply and reassign.
*=
Divide and reassign
/=
Modular division and reassign
%=
Floor division and reassign.
//=
Exponential and reassign
**=
Equal
==
Not equal
!=
Greater than
>
Less than
Greater than or equal
> =
Less than or equal
<=
and
Returns true if both arguments are true
&
or
Returns true if either input is true.
|
not
Returns Boolean inverse
~
nor
Returns true if both inputs are false.
Nand
Returns true if either input is false.
XOR
Returns true if the inputs are different.
XNOR
Returns true if the inputs are the same.
is
Returns true if both variables are the same object.
is not
Returns true if both variables are not the same object.
in
Returns true if a sequence is in an object.
not in
Returns true if a sequence is not in an object.