Q.Which of the following operator evaluates to True if the variable on either side of the operator points towards the same memory location and False otherwise? (A) is (B) is not (C) and (D) or
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →The is operator in Python checks if two variables reference the exact same memory object (identity), not just equal values. The correct answer is (A) is.
The question tests your understanding of Python’s identity operators — is and is not. These are different from equality operators (== and !=). While == compares the value of two objects, is compares their identity — that is, whether they are the same object in memory.
Think of it like two people with identical names. == asks “Do they have the same name?” — yes, they do. is asks “Are they the same person?” — no, they are two different individuals. In Python, two variables can hold equal values but point to different memory locations (e.g., two separate lists with the same elements). The is operator returns True only when both variables refer to the exact same object.
Now let’s go through the options:
-
Option (A):
isThis operator evaluates to
Trueif the two operands refer to the same memory location (same object). For example:a = [1, 2, 3] b = a print(a is b) # True — both point to the same list objectThis matches the description in the question exactly.
-
Option (B):
is notThis is the negation of
is. It returnsTrueif the operands point to different memory locations. So it does the opposite of what the question asks. -
Option (C):
andThis is a logical operator that returns
Trueonly if both operands are truthy. It has nothing to do with memory location. -
Option (D):
or…
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.