Q. Predict the output:
a, b, c = [1,2], [1, 2], [1, 2]
print (a == b)
print (a is b)
Answer :-
Output:-
True
False
>>>
Explanation :-
(i) (a == b) It will return True because It only check the equity of variables
(ii) (a is b) It will return False because It check is id of a equal to b.
>>> id(a)
2129212134144
>>> id (b)
2129206394816
>>>
Here id of a is not equal to id of b.
Sir why its false you tell me because my exam is near
ReplyDeleteExplanation :-
Delete(i) (a == b) It will return True because It only check the equity of variables
(ii) (a is b) It will return False because It check is id of a equal to b.
>>> id(a)
2129212134144
>>> id (b)
2129206394816
>>>
Here id of a is not equal to id of b.
Thanks for solutions 🙏
ReplyDeleteWelcome 😊😊
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )