In this page, you can learn the most important use of python operators.
The operator can be defined as a symbol which is responsible for a particular
operation between two operands. Operators are the pillars of a program on which
the logic is built in a particular programming language. Python provides a
variety of operators described as follows.
There
are some Python supports the following operators
·
Arithmetic
Operators.
·
Relational
Operators.
·
Assignment
Operators.
·
Logical
Operators.
·
Membership
Operators.
·
Identity
Operators.
·
Bitwise
Operators.
Arithmetic Operators
Operators
|
Description
|
//
|
Perform
Floor division(gives integer value after division)
|
+
|
To
perform addition
|
-
|
To
perform subtraction
|
*
|
To
perform multiplication
|
/
|
To
perform division
|
%
|
To
return remainder after division(Modulus)
|
**
|
Perform
exponent(raise to power)
|
Relational Operators:
Operators
|
Description
|
<
|
Less
than
|
>
|
Greater
than
|
<=
|
Less
than or equal to
|
>=
|
Greater
than or equal to
|
==
|
Equal
to
|
!=
|
Not
equal to
|
<>
|
Not
equal to(similar to !=)
|
Assignment Operators:
Operators
|
Description
|
=
|
Assignment
|
/=
|
Divide
and Assign
|
+=
|
Add
and assign
|
-=
|
Subtract
and Assign
|
*=
|
Multiply
and assign
|
%=
|
Modulus
and assign
|
**=
|
Exponent
and assign
|
//=
|
Floor
division and assign
|
Logical Operators:
Operators
|
Description
|
and
|
Logical
AND(When both conditions are true output will be true)
|
or
|
Logical
OR (If anyone condition is true output will be true)
|
not
|
Logical
NOT(Compliment the condition i.e., reverse)
|
Membership Operators:
Operators
|
Description
|
in
|
Returns
true if a variable is in a sequence of another variable, else false.
|
not
in
|
Returns
true if a variable is not in sequence of another variable, else false.
|
Identity Operators:
Operators
|
Description
|
is
|
Returns
true if the identity of two operands are same, else false
|
is
not
|
Returns
true if the identity of two operands is not same, else false.
|
0 comments:
Post a Comment