Operators in Python

7 type of Operators in python

  1. Arithmetic Operators
  2. Comparison Operators
  3. Assignment Operators
  4. Identity Operators
  5. Bitwise Operators
  6. Membership Operators
  7. Logical Operators

Identity Operators

is : Evaluates to ture if the variables on either side of the operator point to the same object and false otherwise

is not : Evaluates to false if the variables on either side of the operator point to the same object and true otherwise


		a=10
		b=10
		print("Both are equal:",a is b)
		print("Both are not equal:",a is not b)	

Output:
Both are equal: True
Both are not equal: False

Bitwise Operators

Comeing Soon...

Membership Operators

in : Evaluates to true if it finds a variable in the specified sequence and false otherwise

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

	
		s1="annu"
		s2="roohi"
		list1=['annu','aman','arun','triloki']
		print(s1 in list1)
		print(s2 not in list1)
	
Output:
True
True	

Logical Operators

a and b :returns a if a is false,b otherwise

a or b :returns b if b is false, a otherwise

a not b :Returns true if a is true ,false otherwise

	
		a=0
		b=1
		print(a and b)
		print(a or b)
		print(not a)
	
Output:
0
1
True