Skip to content
Preptima

Core Python interview questions

Data model, mutability, scoping, comprehensions, and the truthiness and copying gotchas.

3 questions in Python.

medium3

mediumConcept

Why does `is` agree with `==` for some numbers and strings but not others?

Because `is` compares identity while `==` compares value, and CPython reuses objects for small integers and for compile-time string constants. The agreement is an implementation detail of the interpreter you happen to be running, so code that relies on it works until the values change. It also connects interning to the point an interviewer is testing.

5 minentry, mid, senior