Question:

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?

Show Hint

Use is to check if two variables are the same object,
and use == to check if their values are equal.
This is important when comparing mutable objects like lists or custom classes.
  • is
  • is not
  • and
  • or
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

In Python, the is operator checks for object identity,
which means it returns True if two variables point to the same memory location.
This is different from the equality operator == which checks if the values are the same.
For example, two identical lists may have equal values but not the same identity.
The is not operator checks for the opposite — it returns True if the variables do not share the same identity.
The and and or operators are logical operators and do not check memory locations.
Therefore, the operator that checks if both variables refer to the same object in memory is is.
So, the correct answer is option (A).
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions