bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python Identity Operators

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Python Identity Operators?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:
Difference Between is and ==
Identity Operators

Identity Operators

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:

OperatorDescriptionExample
isReturns True if both variables are the same objectx is y
is notReturns True if both variables are not the same objectx is not y

Difference Between is and ==

  • is - Checks if both variables point to the same object in memory
  • == - Checks if the values of both variables are equal

Example

x = [1, 2, 3]

y = [1, 2, 3]

print(x == y)

print(x is y)

Previous

Python Logical Operators

Next

Python Membership Operators