Issues related doubt

I Thinks it is will be True can you mark this as correct…


Answer is false because id (address) will be different for a and b.

1 Like

when two variables are assigned same value they point to same address until value of one or both of them is modified, so answer should be True

1 Like

But not in case of tuples. Here tuples are stored in variables so memory location will be different

1 Like

I think you are using some other language.
Please try this in python

See this

The screenshot was from GFG python3 compiler. when I run the code in vscode and google colab, it is giving False. @sriv.ansh also ran on the program on an online compiler, but if we say online compiler are giving answer True, then why only google colab is giving false.

Yes answer will be False as I know.
May be there will be some issue with online compiler/IDEs

But in Online compiler answer is True. But I thinks Memory utilize available is case of tuple

You can see both id are same.


Try ‘a is b’ in vscode

The Screen Shot I Had shared that was of VS code … :slight_smile:

1 Like

Actually by conceptual as I know tuples takes different memory location even if elements are same inside the tuple. :blush:
And jupyter and colab are giving correct output.
For more you can explore more.

1 Like

If this type of question I’ll get in certification exam to what I’ve to choose True or False :slightly_smiling_face:

1 Like

You have to choose false

@kaushal-ta-ds sir are you sure answer will be false :slightly_smiling_face:??

In the code , the “is” operator is used to check whether two variables refer to the same object in memory. In this case, even though the values of the tuples “a” and “b” are the same, they are two distinct objects in memory.

Therefore, the expression “a is b” will evaluate to False because “a” and “b” are two different tuples with the same values, so they are not the same object in memory.

If you want to check whether the values of two tuples are the same, you can use the “==” operator instead, like this:

a = (1, 2, 3)
b = (1, 2, 3)
print(a == b) # This will output True

This will compare the values of the two tuples, and return True if they have the same values in the same order.

1 Like

please refer above

@sriv.ansh the info given to your search is related to objects inside tuple not another empty tuple. your search is interpreted as ‘does a tuple store its objects in different memory locations(like linked list)’.
Try searching
‘does two empty tuples objects references to same memory location’
something like this
or search
what is output of the code: a=();b=();print(a is b)

maybe you will see explanation or a reference link

1 Like

Nice one :+1: keep it up

1 Like