← Back to videos

Junior Python Interview: Object Comparisons, Membership Testing, and Learning Gaps

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Pre-Junior (2–3 months into fundamentals)

The candidate is progressing on the right track — clearly distinguishing ==, is, and isinstance() and self-correcting when he spots contradictions — but after 2–3 months of study it is still too early for a Junior role due to foundational gaps in comparison dunders, set iteration, and chained comparisons.

Candidate: Gadzhi
Target role: Junior Python Developer

QA and test automation exposure 4 years ago · studying core Python fundamentals from scratch for ~2–3 months

Answers accuracy 13 total
46% score
Theory
3/11 correct · 50%
Live coding
0/2 correct · 25%
Practical task
Not solved

Chained comparison with 'in' and '==': name in ['admin', ...] == True

The candidate predicted True for print(name in ['admin', ...] == True). After seeing False, he tested operator-precedence hypotheses with parentheses and disproved right-to-left grouping when name in ([...] == True) raised TypeError, but did not know Python's comparison-chaining expansion (a in b) and (b == True).

Topics covered Click a topic to filter questions

Candidate strengths

  • + Clear distinction between value equality (==), object identity (is), and class membership (isinstance)
  • + Solid grasp of fast O(1) membership lookup with 'in' on a set versus linear scanning on a list
  • + Ability to catch contradictions in his own answers, stop guessing, and revise his position constructively
  • + Good experimental instinct during live coding, testing operator-precedence hypotheses with parentheses

Areas to improve

  • → Learn how comparisons work in custom classes (__eq__, rich comparison dunders, and default object behavior)
  • → Solidify iteration and container protocols, including iterating over sets with for-loops and __contains__
  • → Master Python's chained comparison rules involving ==, <, >, in, and is
  • → Minimize long silent pauses during interviews by asking clarifying questions while thinking

Questions in this interview

13 / 13
01 ▶ 05:43
What ways exist to compare objects in Python, and how do ==, is, and isinstance() differ?
Theory Data types, numbers & memory
?
Candidate's answer

Clearly distinguished all three: == checks value equality, is checks whether two references point to the exact same object in memory, and isinstance(obj, cls) checks class membership.

Key takeaway

== invokes __eq__ for value equality, is compares object identity (id(a) == id(b)), and isinstance() checks type membership including subclasses.

Open moment on YouTube ↗
#01
02 ▶ 08:29
Are there incomparable objects in Python (e.g., int and str), and what comparison operators exist?
Theory Data types, numbers & memory
?
Candidate's answer

Initially claimed any two objects can always be compared, then corrected himself when asked about comparing an int with a str and listed ==, !=, <, >, <=, >=.

Key takeaway

Equality checks across unrelated types (5 == '5') safely return False in Python 3, whereas ordering comparisons (5 < '5' or ordering complex numbers) raise TypeError.

Open moment on YouTube ↗
#02
03 ▶ 12:47
Can instances of a custom user-defined class be compared by default, and with what?
Theory OOP, classes & dunder methods
?
Candidate's answer

Concluded that without manually defining special methods, a custom class instance cannot be compared with anything by default.

Key takeaway

Every Python class inherits default == and != from object based on identity (is), returning False against other objects, while <, <=, >, >= raise TypeError until implemented.

Open moment on YouTube ↗
#03
04 ▶ 19:40
Which dunder methods implement custom object comparisons, and which exist by default?
Theory OOP, classes & dunder methods
?
Candidate's answer

Correctly noted that default dunders are inherited from object, but could not name the comparison methods and mistakenly thought they work by casting the instance to a built-in type.

Key takeaway

Custom comparisons are defined via rich comparison methods (__eq__, __ne__, __lt__, __le__, __gt__, __ge__, aided by @functools.total_ordering) returning a bool or NotImplemented.

Open moment on YouTube ↗
#04
05 ▶ 22:33
What does the 'in' operator do in Python, and is it classified as a comparison operator?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Accurately explained membership testing returning True or False, though he was unsure whether Python's grammar classifies 'in' under comparison operators.

Key takeaway

In Python's official reference, membership (in, not in) and identity (is, is not) are comparison operators sharing the exact same precedence and chaining behavior as == and <.

Open moment on YouTube ↗
#05
06 ▶ 26:34
How else can you check whether an item belongs to a collection without using the 'in' operator?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Suggested scanning with a for-loop and an if equality check, or manually stepping through iter() and next().

Key takeaway

A manual loop over iter()/next() performs a linear O(n) equality scan, which is also Python's fallback when a container lacks __contains__.

Open moment on YouTube ↗
#06
07 ▶ 28:05
How does membership testing with 'in' differ from a for-loop with 'if' on a list versus a set?
Theory Collections, lists, dicts & hash tables
?
Candidate's answer

Correctly explained that 'in' on a set performs an immediate lookup without scanning all elements, whereas searching a list visits elements sequentially.

Key takeaway

On a set or dict, 'in' performs an O(1) average hash-table lookup, whereas looping with for or searching a list takes O(n) linear time.

Open moment on YouTube ↗
#07
08 ▶ 30:52
How does the 'in' operator work under the hood across container types, and how does it compare to a Python for-loop on a list?
Theory OOP, classes & dunder methods
?
Candidate's answer

Reasoned that 'in' dispatches on the container type (linear scan for list, fast lookup for set), without naming __contains__ or C-level loop execution.

Key takeaway

x in container calls container.__contains__(x) (falling back to iteration); even on a list, C-level list.__contains__ avoids per-item Python bytecode loop overhead.

Open moment on YouTube ↗
#08
09 ▶ 34:35
Can you iterate over a set with a for-loop in Python?
Theory Collections, lists, dicts & hash tables
?
Candidate's answer

Because sets are unordered, mistakenly concluded that iterating over a set with a for-loop is impossible.

Key takeaway

Sets implement __iter__ and fully support for-loop iteration; being unordered only means no positional indexing (s[0] raises TypeError) and no guaranteed traversal order.

Open moment on YouTube ↗
#09
10 ▶ 36:29
What practical limits arise when storing and searching a list with billions of items?
Theory Data types, numbers & memory
?
Candidate's answer

Declined to hypothesize, treating the question as an obscure edge case of the 'in' operator rather than a memory/complexity constraint.

Key takeaway

A list materializes every pointer in RAM (billions of items consume tens of gigabytes and risk MemoryError) and scans in O(n); large datasets require streaming iterators, indexes, or databases.

Open moment on YouTube ↗
#10
11 ▶ 39:37
Why is the Boolean (bool) data type named that way?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly guessed the type was named after a person, though he did not know George Boole's name.

Key takeaway

Boolean is named after 19th-century mathematician George Boole, who formalized the algebraic logic underpinning digital circuits and program conditionals.

Open moment on YouTube ↗
#11
12 ▶ 41:10
What does name = 'admin'; print(name in ['admin', ...] == True) print?
Live coding Control flow, loops & syntactic sugar
?
Candidate's answer

Predicted True, reading the expression left-to-right as (name in [...]) producing True and True == True evaluating to True.

Key takeaway

Python chains all comparison operators (including 'in' and '=='): a in b == True expands to (a in b) and (b == True), which is False because a list does not equal True.

Open moment on YouTube ↗
#12
13 ▶ 45:12
Is False in name in [...] == True caused by operator precedence, and what happens when you add parentheses?
Live coding Control flow, loops & syntactic sugar
?
Candidate's answer

Tested (name in [...]) == True (got True) and then name in ([...] == True) (got TypeError: bool is not iterable), disproving his precedence hypothesis, though he remained stumped on chaining.

Key takeaway

Comparison chaining is neither left- nor right-associative grouping: the middle operand is evaluated once in (a op1 b) and (b op2 c). Avoid redundant == True or parenthesize explicitly.

Open moment on YouTube ↗
#13
Original video description & timecodes

A mock technical interview for a Junior Python Developer position covering object comparison, `==`, `is`, `isinstance()`, comparison operators, the `in` operator, collection membership, and chained comparisons. The video ends with detailed feedback on the candidate’s reasoning, communication, strengths, and areas for further study.