Module 3: Operators in Python
Identity Operators
Identity operators check if two variables point to the same object in memory: is and is not. A common use is comparing a value to None.
About 6 minutes
== compares values. is checks if two names refer to the exact same thing (same identity).
Example code
a = [1, 2] b = [1, 2] c = a print(a == b) # True (same contents) print(a is b) # False (different lists) print(a is c) # True (same list object)
Use `value is None` to check for “no value” — common in data cleaning later.
Practice
Create x = None. Print x is None and x is not None.
Key takeaways
- is / is not check same object, not just equal values.
- Often used with None.
- For equal values of numbers/strings, == is usually enough.
Quick check: Identity Operators
Question 1 of 2
When is `is` commonly used with None?