identity operator
#identity operator
a= 20
b= 20
print ("line1", "a=", a, " : ", id(a), "b=", b, ":", id(b))
if (a is b):
print("line 2 - a and b have same identity")
else:
print ("line 2 - a and b do not have same identity")
if (id(a) == id(b)):
print ("line 3 - a and b have same identitiy")
else:
print ("line 3 - a and b do not have same identity")
b= 30
print ("line 4", "a=", a, ":", id(a), "b=", b, ":", id(b))
if (a is not b):
print("line 5 - a and b do not have same identity")
else:
print("line 5 - a and b have same identity")
a= 20
b= 20
print ("line1", "a=", a, " : ", id(a), "b=", b, ":", id(b))
if (a is b):
print("line 2 - a and b have same identity")
else:
print ("line 2 - a and b do not have same identity")
if (id(a) == id(b)):
print ("line 3 - a and b have same identitiy")
else:
print ("line 3 - a and b do not have same identity")
b= 30
print ("line 4", "a=", a, ":", id(a), "b=", b, ":", id(b))
if (a is not b):
print("line 5 - a and b do not have same identity")
else:
print("line 5 - a and b have same identity")
Comments
Post a Comment