Introduction to operators
What are operators?
Operators are symbols that perform operations on operands(values) or variables, which behave generally like functions. Combination of operators and operands form an expression.
Operators in Python
There are seven set of operators in Python, grouped by the type of operations they perform such as mathematical operations, comparison operations, and logical operations on operands which can be values, variables or constants.
-
Arithmetic Operators:
Arithmetic operators are used to perform mathematical operations, e.g.,+
,-
,/
and so on. -
Assignment Operators: These set of operators are used to assign values to variables, e.g.,
=
,+=
. -
Comparison Operators: Also know as relational operators, and these set includes equality operator
==
, inequality operator!=
and so on. -
Logical Operators: Also know as Boolean operators, includes logical
and
operator,or
operator andnot
operator -
Membership Operators: These set consists of operators such as
in
andnot in
-
Identity Operators: Identity operators in Python includes
is
identity operator andis not
identity operator. -
Bitwise Operators: Bitwise operators performs operations on binary numbers, it includes bitwise
and
operator, bitwise|
operator and so on.
These is a quick overview of available operators in Python, hopefully in the next guides we’ll be able to cover each set of operators in depth.