DS160123 Commonly used operators in python

Date:-12/03/2023
Operators Description Example
1] + Addition 2+3 return 5
2] - Subtraction 4-2 return 2
3] * Multiplication 3*4 return 12
4] / Division 10/5 return 2.0
5] // Floor Division 10//3 returns 3 (integer division)
6] % Modulo 7%3 returns 1 (remainder)
7] ** Exponentiation 2**3 returns 8
8] == Equality 2==2 returns True
9] != Not equal 2!=3 returns True
10] > Grater than 4>2 returns True
11] < Less than 4<2 returns False
12] >= Greater than
or equal to 4>=4 returns True
13] <= Less than or
equal to 4<=2 returns False
14] and Logical and 2>1 and 3>2 returns True
15] or Logical or 2>1 or 3<2 returns True
16] not Logical not not(2>1) returns False
17] in Check if an element
is in a sequence 2 in [1,2,3] Returns True
18] not in Check if an element
is not in a sequence 4 not in [1,2,3] returns True
19] is Check if two objects
have a same identity x is y
20] is not Check if two objects
do not have a same identity x is not y

1 Like

@sms18680

Thank you for your valuable contribution.

1 Like