Operators in python are the symbols used to perform an operation. Some of the most common operators used in Python are
Category | Operators |
Arithmetic Operators | +, -, *, /,%,// |
Relational Operators | ==,!=,<,>,>=,<= |
Assignment Operators | =,+=,-=,*=,/=,%= |
Logical Operators | and, or , not |
You will see example and more detail of all these Python Operators in further sections.
Arithmetic Operators
Here is more detail about the Python supported Arithmetic Operators:
Operator | Explanation | Example |
+ | Used for addition operation | “+” is used as addition operator where 11+2 is evaluated as 13 |
– | Used for the subtraction operation | “-” is used as subtraction operator where 11-2 is evaluated as 9, 2-11 is evaluated as -9 |
* | Used for a multiplication operation | “*” is used as multiplication operator where 11*2 is evaluated as 22 |
/ | Used for division operation | “/” is used as division operator where 11/2 is evaluated as 5.5 |
// | Used for integer division operation | “//” is used for integer division where 11//2 is evaluated as 5 |
% | Used for the modulo operation, consider the expression num 1%num2 which finds the remainder after dividing num1 by num2 | “%” is used as modulo operator where 11%2 is evaluated as 1, 9%11 is evaluated as 9 |
Relational Operators
Here is more detail about the Python supported Relational Operators:
Operator | Explanation | Example |
== | Used for checking the equality of two values/variable | 10==10 is evaluated as True 100==10 is evaluated as False |
!= | Used for checking the in-equality of two values/variable | 10 != 10 is evaluated as False 10 != 100 is evaluated as True |
> | Used for checking the of num1 is greater than num2 in num1 > num2 | 10 > 10 is evaluated as False 100 > 10 is evaluated as True |
< | Used for checking the of num1 is lesser than num2 in num1 < num2 | 10 < 10 is evaluated as False 10 < 100 is evaluated as True |
>= | Used for checking the of num1 is greater than or equal to num2 in num1 >= num2 | 10 >= 10 is evaluated as True 10 >= 100 is evaluated as True |
<= | Used for checking the of num1 is lesser than or equal to num2 in num1 <= num2 | 10 <= 10 is evaluated as True 100 <= 10 is evaluated as False |
Assignment Operators
Here is more detail about the Python supported Assignment Operators:
Operator | Explanation | Example |
= | Used for assigning value to a variable | num=5 Here num is assigned with the value 5 |
+= | Used as short hand assignment operator addition | num=num+1 can be represented using short hand assignment operator as num+=1 |
-= | Used as short hand assignment operator subtraction | num=num-1 can be represented using shorthand assignment operator as num-=1 |
*= | Used as short hand assignment operator multiplication | num=num1 can be represented using shorthand assignment operator as num=1 |
/= | Used as short hand assignment operator division | num=num/1 can be represented using shorthand assignment operator as num/=1 |
%= | Used as short hand assignment operator modulo operation | num=num%1 can be represented using short hand assignment operator as num%=1 |
Logical Operator
Here is more detail about the Python supported Logical Operators:
Operators | Description |
AND | The result will be true if both the expressions are true. If any one or both the expressions are false, the result will be false. |
OR | The result will be true, even if one of the expressions is true. If both the expressions are false, the result will be false. |
NOT | If the expression is true, the result will be false and vice versa. |
If A and B are two relational expressions, say A = (Num1>2000), B= (Num2>100), the result of combining A and B using logical operator is based on the result of A and B as shown below:

You can also try all these operators in problem mentioned in Python Exercises.
You must log in to post a comment.