Course Content
1.
Why Learn Python?
4 min
5 min
0
2.
What is the Best Software for Learning Python?
5 min
5 min
0
3.
Python List Functions
0 min
1 min
0
4.
All Python Operators (with examples)
0 min
1 min
0
5.
How to Declare a Variable in Python
2 min
3 min
0
6.
Variable Naming Rules and Conventions
8 min
6 min
0
7.
Use Descriptive Variable Names
4 min
3 min
0
8.
Integers and Floats
0 min
6 min
0
9.
Familiar Arithmetic (math) Operators
0 min
2 min
0

- Save
- Run All Cells
- Clear All Output
- Runtime
- Download
- Difficulty Rating
Loading Runtime
What is an "operator"?
An "operator" is a symbol that does something in Python. It does an "operation".
Typically, an operator has values on the left and right side of it. These values are called "operands". An operand is any value an operator acts on.
For example, if I write the line 2 + 3, the plus sign (addition operator) is the operator, and the numbers (2 and 3) are the operands.
Categories of Operators
There are seven categories of operators in Python. They are:
Arithmetic Operators
Useful for doing math with Python. You might need to use parentheses in conjunction with these arithmetic operators ((, )) if you want to enforce a specific order of operations.
- Addition Operator:
+ - Subtraction Operator:
- - Multiplication Operator:
* - Division Operator:
/ - Floor Division Operator:
// - Modulus Operator:
% - Exponentiation Operator:
**
Addition Operator
5Subtraction Operator
3Multiplication Operator
15Division Operator
1.3333333333333333Floor Division Operator
1Modulus Operator
2Exponentiation Operator
8Comparison Operators
Used to compare two values. Each of these operators results in one of two boolean values (true or false).
- Equality Operator:
== - Inequality Operator:
!= - Greater Than Operator:
> - Less Than Operator:
< - Greater Than or Equal To Operator:
>= - Less Than or Equal To Operator:
<=
Equality Operator
falseInequality Operator
trueGreater Than Operator
trueLess Than Operator
falseGreater Than or Equal To Operator
trueLess Than or Equal To Operator
falseLogical Operators
andOperatororOperatornotOperator
and Operator
truefalsefalseor Operator
truetruefalsenot Operator
falsetrueBitwise Operators
Converts integers to their binary representation and then compares each corresponding pair of binary bits using the designated method. The resulting binary number is then translated back into decimal format.
- Bitwise AND Operator:
& - Bitwise OR Operator:
| - Bitwise XOR Operator:
^ - Bitwise NOT Operator:
~ - Bitwise Right Shift Operator:
>> - Bitwise Left Shift Operator:
<<
Bitwise AND Operator
3Bitwise OR Operator
15Bitwise XOR Operator
11Bitwise NOT Operator
-8Bitwise Right Shift Operator
28672Bitwise Left Shift Operator
0Assignment Operators
- Assignment Operator:
= - Addition Assignment Operator:
+= - Subtraction Assignment Operator:
-= - Multiplication Assignment Operator:
*= - Division Assignment Operator:
/= - Modulus Assignment Operator:
%= - Floor Division Assignment Operator:
//= - Exponentiation Assignment Operator:
**= - Bitwise AND Assignment Operator:
&= - Bitwise OR Assignment Operator:
|= - Bitwise XOR Assignment Operator:
^= - Bitwise Right Shift Assignment Operator:
>>= - Bitwise Left Shift Assignment Operator:
<<= - Walrus Operator:
:=
Assignment Operator
3Addition Assignment Operator
7Subtraction Assignment Operator
6Multiplication Assignment Operator
12Division Assignment Operator
6Modulus Assignment Operator
0Floor Division Assignment Operator
7Exponentiation Assignment Operator
49Bitwise AND Assignment Operator
4Bitwise OR Assignment Operator
12Bitwise XOR Assignment Operator
7Bitwise Right Shift Operator
7Bitwise Left Shift Operator
15360Walrus Operator
[4, 16, 36, 64, 100]
Identity Operators
Compares the memory locations of two objects.
isOperatoris notOperator
is Operator
truefalseis not Operator
falsetrueMembership Operators:
Tests if a value is found in a sequence (string, list tuple, dictionary, etc.).
inOperatornot inOperator
in Operator
truefalsenot in Operator
falsetrue