Create a program to display memory locations of two variables using id() function, and then use identity operators to compare whether two objects are same or not.
a=25
b=25
if(a is b):
print("Both are same")
else:
print("Both are not same")
print("Ids of a and b are")
print("id of a is %i"%id(a))
print("id of b is %i"%id(b))
lst1=[1,2,3,4]
lst2=[1,2,3,4]
if(lst1 is lst2):
print("Both list are same")
else:
print("Both list are not same")
print("Ids of list1 and list2 are")
print("id of List1 is %i"%id(lst1))
print("id of List2 is %i"%id(lst2))
a=25
b=25
if(a is b):
print("Both are same")
else:
print("Both are not same")
print("Ids of a and b are")
print("id of a is %i"%id(a))
print("id of b is %i"%id(b))
lst1=[1,2,3,4]
lst2=[1,2,3,4]
if(lst1 is lst2):
print("Both list are same")
else:
print("Both list are not same")
print("Ids of list1 and list2 are")
print("id of List1 is %i"%id(lst1))
print("id of List2 is %i"%id(lst2))