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?✗ Incorrect
is checks if two variables point to the same object in memory.What will
5 is 5 return in Python?✗ Incorrect
Small integers are cached in Python, so
5 is 5 returns True.If
a = [1, 2] and b = [1, 2], what does a is b return?✗ Incorrect
Lists with the same content are different objects, so
a is b is False.Which operator checks if two variables do NOT point to the same object?
✗ Incorrect
is not checks if two variables are not the same object.What is the result of
'hello' is 'hello' in Python?✗ Incorrect
Python often interns short strings, so identical string literals usually point to the same object, but this behavior can depend on the Python implementation.
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.