Professional Documents
Culture Documents
operator
operator
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
TYPES OF OPERATORS IN PYTHON
Arithmetic Operators
Assignment Operators
Logical Operators
Bitwise Operators
Special Operators
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
ARITHMETIC OPERATORS
Arithmetic operators are used to perform mathematical
operations like addition, subtraction, multiplication and division.
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
RELATIONAL OPERATORS
>
Greater than: True if left operand is greater than the x>y
right
< Less than: True if left operand is less than the right x<y
>=
Greater than or equal to: True if left operand is greater x >= y
than or equal to the right
<=
Less than or equal to: True if left operand is less than x <= y
or equal to the right
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
ASSIGNMENT OPERATORS
Assignment operators are used to assign values to the variables.
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
OPERATOR DESCRIPTION SYNTAX
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
LOGICAL OPERATORS
NOT operations.
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
BITWISE OPERATORS
| Bitwise OR x|y
~ Bitwise NOT ~x
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
IDENTITY OPERATORS
is and is not are the identity operators in Python. They are used
to check if two values (or variables) are located on the same part
of the memory. Two variables that are equal does not imply that
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
MEMBERSHIP OPERATORS
value.
Operator Meaning Example
True if value/variable is
in 5 in x
found in the sequence
True if value/variable is
not in not found in the 5 not in x
sequence
D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G