Python Operators

Arithmetical operators

+          Addition           5 + 2 7
-           Subtraction      5 - 2 3
*           Multiplication   5 * 2 10
/           Division           5 / 2 2.5
%         Modulus          5 % 2 1
**         Exponent         5 ** 2 25
//          Floor Division 5 // 2 2

Conditional Operators
==        Equal                                       5 == 2 False
!=         Not equal                                 5 != 2 True
>          Greater than                            5 > 2 True
<          Less than                                 5 < 2 False
>=        Greater or equal to                  5 >= 2 True
<=        Less than or equal to   5 <= 2 False

Assignment Operators

=                      Assignment                 a = 5 5
+=                    Addition                       a = 5 a += 2    7
-=                     Subtraction                  a = 5 a -= 2 3
*=                    Multiplication               a = 5 10 a *= 2
/=                     Division                       a = 5 a /= 2 2.5
%=                   Modulus                      a = 5 a %= 2 1
**=                   Exponent                     a = 5 a **= 2  25
//=                    Floor Division a = 5 a //= 2 2

Logical Operators

and     
or
not

Membership Operators

in                     Evaluates to true if it finds a variable in the specified sequence

not in               Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.

Identity Operators

is                      Evaluates to true if the variables on either side of the operator point to the same object and false otherwise.
Ex: x is y, here is results in 1 if id(x) equals id(y).

is not               Evaluates to false if the variables on either side of the operator point to the same object and true otherwise.
Ex: x is not y, here is not results in 1 if id(x) is not equal to id(y).

 

 

For
More Explanation
&
Online Classes

Contact Us:
+919885348743