← Back to videos

Junior Python interview: is the theory from the textbook enough?

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Pre-Junior / early Junior (textbook theory without hands-on verification)

Rated not ready yet: the candidate recalls textbook rules (citing Mark Lutz) and solved the basic try/finally + break snippet cleanly, but stumbles on follow-up edge cases, contradicts himself, and drifts off-topic instead of answering the exact question asked. He needs to move from memorizing authoritative books to verifying mechanics hands-on.

Candidate: Igniy
Target role: Junior Python Developer

30 y/o · studying Python for ~7 months (Core Python, SOLID principles, basic infrastructure), preparing for his first developer job

Answers accuracy 12 total
42% score
Theory
1/8 correct · 38%
Live coding
1/4 correct · 50%
Practical task
Solved

Behavior of try / finally when breaking out of a while True loop

The candidate accurately traced the while True loop with try (print 'A' and break), finally (print 'B'), and trailing print('C') on the first attempt, explaining that finally executes even when exiting via break. In follow-up discussion he missed software cases that bypass finally (such as os._exit()) and contradicted himself on try/except granularity and readability.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Solved the while True + break + try/finally code snippet accurately on the first try, predicting A, B, C
  • + Good baseline familiarity with the iterator protocol (__iter__ / __next__) and two-pointer / sliding-window use cases for while-loops
  • + Awareness of BaseException vs Exception hierarchy and why bare BaseException catches should be avoided
  • + Composure under nervousness and willingness to stay engaged in technical discussion

Areas to improve

  • → Test textbook claims hands-on in code and official docs to understand 'why' and discover edge cases
  • → Stay focused on the exact question asked and use clarifying questions instead of drifting into tangential details
  • → Clarify core concepts: spaghetti code without goto, where __iter__/__next__ live (not on object), and bugs/errors vs exception objects
  • → Learn software scenarios where finally does not run (os._exit(), SIGKILL) and practical trade-offs between if-validation (LBYL) and try/except (EAFP)

Questions in this interview

12 / 12
01 ▶ 03:23
What is spaghetti code, and can it exist in Python even though Python has no goto statement?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Tied spaghetti code strictly to the historical goto statement and insisted that removing goto from a language eliminates spaghetti code.

Key takeaway

While coined around goto, spaghetti code today refers to any tangled, deeply nested, tightly coupled control flow and shared state, which is just as possible in Python.

Open moment on YouTube ↗
#01
02 ▶ 06:30
What loop constructs exist in Python, and are comprehensions a separate loop statement?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Named while and for, initially grouping single-line comprehension expressions as a loop subtype before settling on the two loop statements.

Key takeaway

Python has exactly two loop statements (for and while); comprehensions and generator expressions are value-producing expressions rather than loop statements.

Open moment on YouTube ↗
#02
03 ▶ 07:41
What is the conceptual difference between 'for' and 'while' loops, and when should you choose each?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Gave solid practical examples (for over iterables, while for two pointers and infinite loops), but emphasized speed optimization rather than definite versus indefinite iteration.

Key takeaway

Use 'for' to iterate over elements of an iterable (definite/data-driven iteration) and 'while' to repeat until an arbitrary condition changes (indefinite/condition-driven iteration).

Open moment on YouTube ↗
#03
04 ▶ 12:54
Why is a 'for' loop often faster than a manual 'while' loop, and is 'while True' slow too?
Theory Python internals, bytecode & runtime
?
Candidate's answer

Mistakenly claimed 'for' compiles to bytecode faster and that 'while True' evaluates True == True on every step, falling back on citing Mark Lutz without knowing the runtime reason.

Key takeaway

'for' beats manual indexed 'while' by advancing iterators in C via FOR_ITER without Python index arithmetic, whereas 'while True' compiles away the condition check into an unconditional bytecode jump.

Open moment on YouTube ↗
#04
05 ▶ 20:16
How does iteration work via __iter__ and __next__, and do all objects (including object and int) have those methods?
Theory Decorators, iterators, generators & context managers
?
Candidate's answer

Correctly named __iter__ and __next__ for iteration, but mistakenly claimed base class object defines them and that int inherits and shadows them to raise an error.

Key takeaway

Neither object nor int defines __iter__ or __next__; an iterable implements __iter__(), while the returned iterator implements both __iter__() and __next__().

Open moment on YouTube ↗
#05
06 ▶ 25:41
What is the difference between an error and an exception in programming and in Python?
Theory Exceptions & debugging
?
Candidate's answer

Rightly noted that exceptions interrupt control flow even for non-errors like KeyboardInterrupt under BaseException, but conflated 'error' with a printed traceback and got confused on cause vs effect.

Key takeaway

An error is a flaw in logic, input, or state, whereas an exception is Python's runtime signaling object used to unwind the call stack (including non-error signals like StopIteration).

Open moment on YouTube ↗
#06
07 ▶ 28:45
What is a traceback in Python?
Theory Exceptions & debugging
?
Candidate's answer

Explained that a traceback is the diagnostic report showing the call history, exception type (e.g., ValueError), and message where execution failed.

Key takeaway

A traceback records the chain of active stack frames down to the exact line where an exception was raised.

Open moment on YouTube ↗
#07
08 ▶ 35:19
What does a while True loop containing try: print('A'); break and finally: print('B'), followed by print('C'), output?
Live coding Exceptions & debugging
?
Candidate's answer

Confidently predicted A, B, C on the first try: 'A' prints, break exits the loop, finally still runs before leaving the try block ('B'), and 'C' prints after the loop.

Key takeaway

A finally clause executes whenever control leaves the try suite — whether normally, via an exception, or via return, break, or continue.

Open moment on YouTube ↗
#08
09 ▶ 39:07
Are there software scenarios (without power loss) where a Python finally block will not execute?
Live coding Exceptions & debugging
?
Candidate's answer

Insisted that aside from hardware power loss, no Python code can prevent a finally block from executing.

Key takeaway

finally is skipped if the process terminates immediately via os._exit(), receives SIGKILL, crashes with a C-level segfault, or hangs forever inside the try block.

Open moment on YouTube ↗
#09
10 ▶ 41:17
Why shouldn't you wrap an entire module in one giant try/except, and doesn't wrapping every other line hurt readability too?
Live coding Exceptions & debugging
?
Candidate's answer

Correctly argued that a giant try/except obscures where and why an error occurred, but then contradicted himself by claiming that wrapping every second line in try/except does not hurt readability.

Key takeaway

Wrap only narrow operations whose specific exception you can meaningfully handle at that level, letting unexpected errors propagate to top-level boundary handlers.

Open moment on YouTube ↗
#10
11 ▶ 48:50
Do you always need try/except (e.g., when dividing by user input), or what alternative approaches exist?
Live coding Exceptions & debugging
?
Candidate's answer

Agreed that pre-validating input with if/else avoids try/except for simple cases while try/except helps when preconditions are hard to enumerate, but could not suggest further patterns.

Key takeaway

Python balances LBYL (upfront if-checks and schema validation at input boundaries) with EAFP (try/except around I/O, parsing, and race-prone operations).

Open moment on YouTube ↗
#11
12 ▶ 01:17:43
Are architectural principles like SOLID's Single Responsibility Principle strict axioms or pragmatic guidelines?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Asked during feedback how abstract principles like Single Responsibility can be verified empirically, treating them almost as axioms from authoritative books.

Key takeaway

Design principles like SOLID and DRY are pragmatic heuristics for managing coupling and change, not rigid axioms — engineers apply them with context and trade-offs in mind.

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

A mock interview for the role of Junior Python Developer. We discuss for and while loops, iterators, exceptions and try/finally blocks, and analyse common mistakes in candidates’ answers. At the end, we provide detailed feedback to the candidate and recommendations on how best to prepare for technical interviews.

Timestamps:

00:00 Start
00:37 Introductions and interview format
03:23 What is spaghetti code?
06:30 for and while loops: what’s the difference?
18:20 How iterators and next() work
25:40 Error or exception?
35:05 Practical exercise with try/finally
41:15 How to use try/except correctly?
52:30 Candidate’s self-assessment
54:20 Feedback