num1
and num2
both are 3.5 and num1 == num2
gives True
, but for is
operator it is False
.
Look at the below code,
Input:
num1 = 3.5
num2 = float(input('num2:')) # num2 stands for 2nd number
print(num1 == num2)
print(num1 is num2)
Output:
num2:3.5
True
False
num1
andnum2
both are 3.5 andnum1 == num2
givesTrue
, but foris
operator it isFalse
.
Why is id(num1) != id(num2)
?