difference between == and is in python code example

Example 1: python test for equality

0 == 0
#True

1 == 0
#False

0 = 0
1 = 0
#Error

Example 2: python is

The is keyword is used to test if two objects refer to the same object.

Example 3: diff between / and // in python

#this operator(//) return the quotien of the division , specifically the int quotein
print(5//2)
# 2 
#this operator(/) return us the exact solution no matter if its float type or anything
print(5/2)
# 2.5

Example 4: == in python

The == operator compares the values of both the operands and checks for value equality. Whereas is operator checks whether both the operands refer to the same object or not. ... Hence list1 and list2 refer to different objects. We can check it with id() function in python which returns the “identity” of an object.

Example 5: difference between % and // in python

# The true div operator (//) return the quotien of a division
print(5 // 2)
# 2

# The modulo operator (%) returns the reminder of a division
print(5 % 1)
# 1