← Back to videos

Junior Python interview: 3 lines of code and basics

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Early Junior (commercial experience, but major gaps in CS & Python fundamentals)

Despite ~1 year of commercial Junior work, the interview uncovered major confusion in CS fundamentals and Python's basic type hierarchy, culminating in failing a 3-line code snippet. Before aiming for Junior+/Middle interviews, the candidate needs to step back and solidify foundational knowledge (memory hierarchy, arbitrary-precision int, bool subclassing int, and generator expressions).

Candidate: Rafi
Target role: Junior Python Backend

20 y/o · 4th-year CS student in Almaty with ~1 year of commercial experience as a Junior Python Backend developer (FastAPI) at a bank

Answers accuracy 12 total
38% score
Theory
1/8 correct · 44%
Live coding
1/4 correct · 25%
Practical task
Not solved

Three lines of code: True / 2 and generator expression sum(n > 0 for n in nums)

The candidate predicted two errors: a TypeError on True / 2 and a SyntaxError on sum(n > 0 for n in nums) without square brackets. After the code ran and printed 3, he misread n > 0 as a filter over nums rather than a boolean expression yielding True (1) and False (0) to count positive items.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Confident, composed communication and an open, non-defensive attitude toward critical feedback
  • + Basic grasp of mutable vs immutable data types, custom classes, and root inheritance from object
  • + Correct conceptual distinction between a heterogeneous Python list and a homogeneous typed array
  • + Willingness to test isolated hypotheses during debugging (e.g., verifying sum([1, 2, 3]) separately)

Areas to improve

  • → Clean up CS fundamentals: numeral systems (human notation vs binary storage) and memory hierarchy (RAM, ROM/firmware, SSD/HDD storage, CPU cache)
  • → Master Python's numeric hierarchy: arbitrary-precision int and bool as a subclass of int (True == 1, False == 0)
  • → Distinguish generator expressions from list comprehensions, and mapping expressions (n > 0 for n in nums) from filtering clauses (if n > 0)
  • → Stop and state 'I don't know' early rather than compounding speculative guesses

Questions in this interview

12 / 12
01 ▶ 03:47
How are Python data types grouped by mutability, and why does the language distinguish mutable from immutable types?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly grouped mutable (list, dict) vs immutable (int, float, str, tuple) types and cited predictability against accidental side effects, while missing technical reasons like hashability for dict/set keys.

Key takeaway

Beyond preventing aliasing bugs, immutability enables constant hashes for dict/set keys, safe sharing across threads, and interpreter object caching.

Open moment on YouTube ↗
#01
02 ▶ 07:10
Can you define custom data types, make them immutable, and subclass built-in Python types?
Theory OOP, classes & dunder methods
?
Candidate's answer

Correctly explained creating custom types via class and subclassing built-ins, but vaguely guessed immutability is configured by a dunder method that changes object IDs.

Key takeaway

Custom class instances are mutable by default; immutability is achieved via @dataclass(frozen=True), NamedTuple, or overriding __setattr__ to block mutation.

Open moment on YouTube ↗
#02
03 ▶ 10:07
Do built-in Python types inherit from one another, what is the root class, and how can you inspect parent classes programmatically?
Theory OOP, classes & dunder methods
?
Candidate's answer

Recalled root class object and type(), guessing a special class attribute exists to inspect parents, without naming __bases__, __mro__, issubclass(), or bool inheriting from int.

Key takeaway

All Python 3 types inherit from object (notably bool subclasses int); parent lineages can be inspected via cls.__bases__, cls.mro(), or issubclass().

Open moment on YouTube ↗
#03
04 ▶ 15:00
What value range and memory size does Python's int type have?
Theory Data types, numbers & memory
?
Candidate's answer

Mistakenly applied fixed-width 32-bit limits (±2 billion) to Python's int while misstating its size as '8 bits'.

Key takeaway

Python 3's int has arbitrary precision with no ±2 billion overflow limit; a PyLongObject starts around 28 bytes and grows dynamically up to available RAM.

Open moment on YouTube ↗
#04
05 ▶ 16:13
What is a bit, and how do RAM, ROM, and persistent disk storage differ in a computer?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly explained bits as transistor states and contrasted volatile RAM with persistent SSD/HDD storage, but conflated disk storage with ROM (ПЗУ) and claimed non-erasable read-only memory does not exist.

Key takeaway

Computer architecture separates volatile RAM and CPU caches/registers from mass storage (SSD/HDD) and firmware ROM/EEPROM used to boot hardware.

Open moment on YouTube ↗
#05
06 ▶ 22:12
What is the Boolean (bool) type, where does its name come from, and why is it needed?
Theory Data types, numbers & memory
?
Candidate's answer

Defined True and False, connected the name to the mathematician behind Boolean algebra, and illustrated how bool drives conditional branching in algorithms.

Key takeaway

Named after George Boole, bool and its logical operations (and, or, not) underpin both hardware logic gates and software branching.

Open moment on YouTube ↗
#06
07 ▶ 28:35
Why are octal and hexadecimal numeral systems used, and do they consume less computer memory than binary?
Theory Data types, numbers & memory
?
Candidate's answer

Mistakenly argued that hexadecimal representation saves physical computer memory compared to binary and drew an incorrect analogy to IPv4 vs IPv6 address exhaustion.

Key takeaway

Hardware always stores bits in binary: 100, 0b1100100, and 0x64 produce the exact same int in memory, while hexadecimal exists purely for compact human readability.

Open moment on YouTube ↗
#07
08 ▶ 36:04
How many values does Python's bool type have, and does None belong to bool?
Theory Data types, numbers & memory
?
Candidate's answer

Briefly wavered on whether None counts as a third bool value before clarifying that bool has strictly two instances (True and False) while None is a separate type that evaluates to falsy in conditionals.

Key takeaway

bool has exactly two singleton instances (True and False); None has type NoneType and merely converts to False via bool(None).

Open moment on YouTube ↗
#08
09 ▶ 45:29
How does a Python list differ from a classic array?
Live coding Collections, lists, dicts & hash tables
?
Candidate's answer

Explained that a classic array restricts elements to a single homogeneous type, whereas nums = [...] in Python is a list capable of holding mixed object types.

Key takeaway

Python's list stores pointers to arbitrary heterogeneous PyObjects, whereas array.array and NumPy ndarrays store contiguous homogeneous C values.

Open moment on YouTube ↗
#09
10 ▶ 46:57
Is wtf = True / 2 valid in Python, and what value and type does it produce?
Live coding Data types, numbers & memory
?
Candidate's answer

Predicted a TypeError, believing a bool cannot be divided by an int in standard Python.

Key takeaway

Because bool subclasses int with True == 1 and False == 0, True / 2 evaluates 1 / 2 and returns 0.5 (float).

Open moment on YouTube ↗
#10
11 ▶ 51:25
Is sum(n > 0 for n in nums) without square brackets a SyntaxError in Python?
Live coding Decorators, iterators, generators & context managers
?
Candidate's answer

Claimed that omitting square brackets around the comprehension inside sum(...) would fail with a SyntaxError.

Key takeaway

sum(expr for x in iterable) passes a lazy O(1)-memory generator expression directly to sum(); parentheses can be shared when it is the sole call argument.

Open moment on YouTube ↗
#11
12 ▶ 53:43
Why does print(sum(n > 0 for n in nums)) print 3 when nums contains positive elements 3, 4, and True / 2?
Live coding Control flow, loops & syntactic sugar
?
Candidate's answer

Misread n > 0 as filtering positive numbers (confusing it with sum(n for n in nums if n > 0)) and could not figure out why the output was 3 instead of summing 3 and 4.

Key takeaway

Without an 'if' filter clause, (n > 0 for n in nums) yields boolean results (True == 1, False == 0) for each item, so sum() counts how many elements are positive (three items: 3, 4, and 0.5).

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

A mock interview for the role of Junior Python Developer.
We discuss data types, `bool`, `int`, memory, number systems and the basics of computer science. At the end, there’s an unexpected live coding session that revealed the main issue: it wasn’t syntax, but a fundamental understanding of Python.

Timecodes

00:00 — Start
00:25 — Getting to know the candidate
03:47 — Data types in Python
07:10 — User-defined classes and inheritance
15:00 — `int`, bits and computer memory
22:12 — The Boolean data type
25:01 — Boolean logic and number systems
43:29 — Live code: True / 2 and an unexpected result
58:06 — The candidate’s self-assessment
01:00:12 — Detailed feedback on the interview