Intermediate
Python
Q57 / 101
What is the difference between is and == for small integers?
Correct! Well done.
Incorrect.
The correct answer is B) For integers -5 to 256, CPython caches objects so is may coincidentally return True, but == is the correct equality check
B
Correct Answer
For integers -5 to 256, CPython caches objects so is may coincidentally return True, but == is the correct equality check
Explanation
CPython caches small integers (-5 to 256), so a is b may be True for them — but this is an implementation detail, not guaranteed. Always use == for value comparison.
Progress
57/101