( == ) and Is Operator in Python

 ( == ) Double equal to operator

The double equal operator compares the values of both the operands and checks for value equality.

Example #1:-

a = 5
b = 5
 if a == b:
    print(True)
else:
    print(False)
Python

Output :-

True 
Markup

is operator

is operator checks whether both operands refer to the same object or not means both refers to same memory location or not.

It check only both variables refer to same memory location.\

Example #2 :-

a = 5
b = 3

if a is b:
    print(True)
else:
    print(False)
Markup

Output :-

False
Markup

It return False because the value of the variables are same but the memory location of both variables are different.

I hope you understand the concept of ( == ) and is operator in python. If you have any query or suggestion please do a comment.

Thank you.

Comments

Popular posts from this blog

⚠️How to create a virus in termux app ?

List in Python

How To Install Metasploit In Termux App ?