0
0
Pythonprogramming~5 mins

Identity operators (is, is not) in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the is operator check in Python?
The is operator checks if two variables point to the exact same object in memory.
Click to reveal answer
beginner
What is the difference between == and is?
== checks if values are equal, while is checks if two variables are the same object in memory.
Click to reveal answer
beginner
What does the is not operator do?
is not checks if two variables do NOT point to the same object in memory.
Click to reveal answer
beginner
Given a = [1, 2] and b = a, what will a is b return?
It will return True because both a and b point to the same list object.
Click to reveal answer
intermediate
Why might a == b be True but a is b be False?
Because a and b have the same value but are different objects in memory.
Click to reveal answer
What does is check in Python?
AIf two variables refer to the same object
BIf two variables have the same value
CIf two variables are of the same type
DIf two variables are both numbers
What will 5 is 5 return in Python?
AError
BFalse
CTrue
DDepends on Python version
If a = [1, 2] and b = [1, 2], what does a is b return?
ATrue
BFalse
CDepends on list size
DError
Which operator checks if two variables do NOT point to the same object?
A!=
B!==
Cnot equal
Dis not
What is the result of 'hello' is 'hello' in Python?
ADepends on Python implementation
BFalse
CError
DTrue
Explain in your own words what the is operator does in Python.
Think about whether two variables are the exact same thing, not just equal.
You got /3 concepts.
    Describe a situation where a == b is True but a is b is False.
    Consider two separate lists with the same content.
    You got /3 concepts.