← Back to videos

Mock interview with Pyotr for a Junior Python developer position

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Junior- (strong coding logic, gaps in theory & clean code)

The candidate reads code fluently and solved the nested-scope nonlocal task effortlessly, but lost confidence under follow-up questioning and missed most foundational theory topics (object/metaclass model, OOP principles, namespace vs scope). A competitive-programming focus also left blind spots in PEP 8 style and pure-function design, resulting in a 'not yet' verdict.

Candidate: Pyotr
Target role: Junior Python Developer

20 y/o · completed Yandex Practicum's Extended Python course and finishing Algorithms & Data Structures, practices competitive/algorithmic problems, builds pet projects, learning C++

Answers accuracy 14 total
54% score
Theory
2/10 correct · 50%
Live coding
2/4 correct · 62%
Practical task
Solved

Nested functions, modifying enclosing variables via nonlocal, and code review

The candidate immediately traced global, enclosing, and local 'value' bindings to predict the exact output, contrasted list mutation with int immutability, and wrote 'nonlocal value' correctly on the first try. During code review, he flagged readability overhead, magic numbers, name shadowing, and missing __main__ guard, while missing pure-function side-effect concerns and minor PEP 8 details.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Fast comprehension of tricky code snippets and accurate mental tracing of nested scopes
  • + Confident practical command of nonlocal and in-place mutation vs immutable rebinding
  • + Strong algorithmic foundation and receptive attitude toward feedback

Areas to improve

  • → Master Python's object model: base class object vs metaclass type, function classes, and Ellipsis
  • → Clearly distinguish namespaces (where names live) from scopes (where names are directly visible)
  • → Review core OOP pillars (encapsulation, inheritance, polymorphism, abstraction) and programming paradigms
  • → Shift from competitive-coding habits to production engineering: pure functions, PEP 8, and maintainability
  • → Build confidence defending correct answers under probing follow-up questions

Questions in this interview

14 / 14
01 ▶ 03:54
What are data types in Python and what categories exist?
Theory Data types, numbers & memory
?
Candidate's answer

Explained that types define how values live in memory and split into mutable and immutable types, citing numbers, bool (as a numeric subtype), and strings.

Key takeaway

An object's type is fixed at creation, dictates its supported operations, and classifies it as mutable or immutable.

Open moment on YouTube ↗
#01
02 ▶ 04:39
What do you do when built-in Python types aren't enough, and how do types, classes, and object relate?
Theory OOP, classes & dunder methods
?
Candidate's answer

Suggested defining a custom class and noted inheritance from object, but conflated subclassing with instantiation by calling int an instance of object.

Key takeaway

Every class in Python 3 implicitly inherits from object, while concrete values like 5 are instances of their class (int).

Open moment on YouTube ↗
#02
03 ▶ 08:30
What does 'everything in Python is an object' mean, and is a class itself an object?
Theory OOP, classes & dunder methods
?
Candidate's answer

Agreed everything is an object in memory, but mistakenly guessed that a class is an instance of object before hesitating.

Key takeaway

Classes themselves are runtime objects in Python: every standard class is an instance of metaclass 'type' and a subclass of 'object'.

Open moment on YouTube ↗
#03
04 ▶ 10:06
Can you instantiate an empty class 'class MyClass: pass' without defining __init__?
Theory OOP, classes & dunder methods
?
Candidate's answer

Initially thought MyClass() would fail without __init__, then reasoned it works when called with no arguments.

Key takeaway

Every Python 3 class implicitly inherits default __new__ and __init__ implementations from object, so empty classes instantiate cleanly.

Open moment on YouTube ↗
#04
05 ▶ 13:37
What do type(MyClass) and type(type) return, and why does type point to itself?
Theory Python internals, bytecode & runtime
?
Candidate's answer

Seeing <class 'type'>, conflated metaclass instantiation with inheritance and could not explain how type is an instance of itself.

Key takeaway

type is the default metaclass (type(MyClass) is type); CPython terminates metaclass recursion at the C level by making type an instance of itself and a subclass of object.

Open moment on YouTube ↗
#05
06 ▶ 16:54
Is a Python function an object, and what class is it an instance of?
Theory Functions, scopes & closures
?
Candidate's answer

Correctly noted a function is a callable object implementing __call__, but guessed its class is type and doubted a 'function' class exists.

Key takeaway

A user-defined function is an instance of class 'function' (types.FunctionType), implementing both __call__ and the descriptor protocol (__get__).

Open moment on YouTube ↗
#06
07 ▶ 17:49
What is 'pass' in Python, and what else can serve as the body of a stub function or class?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Defined pass as a no-op keyword required where Python syntax expects an indented block, noting a docstring literal works similarly.

Key takeaway

The pass statement compiles to a no-op while satisfying Python's grammatical requirement for a non-empty indented block.

Open moment on YouTube ↗
#07
08 ▶ 18:50
What are '...' and 'Ellipsis' inside a function body, and why do literals work there while 'continue' fails?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly predicted '...' and 'Ellipsis' run cleanly whereas 'continue'/'break' fail outside loops, but confused the Ellipsis singleton with a class.

Key takeaway

Both '...' and 'Ellipsis' evaluate to the singleton instance of types.EllipsisType; any valid expression statement is allowed in a function body, commonly used for typing stubs.

Open moment on YouTube ↗
#08
09 ▶ 27:06
What is Object-Oriented Programming, and does merely using Python objects mean you are writing OOP code?
Theory OOP, classes & dunder methods
?
Candidate's answer

Reduced OOP to 'using classes and object interactions', getting stuck when asked if procedural Python counts as OOP and omitting core OOP pillars.

Key takeaway

Using built-in runtime objects isn't OOP by itself; OOP is an architectural paradigm grounded in encapsulation, inheritance, polymorphism, and abstraction.

Open moment on YouTube ↗
#09
10 ▶ 30:53
What programming paradigms exist besides OOP, and which ones does Python support?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Described procedural programming accurately using C, but doubted whether functional programming is a paradigm and whether Python supports multiple paradigms.

Key takeaway

Python is multi-paradigm, supporting procedural, object-oriented, and functional programming patterns (higher-order functions, closures, immutability).

Open moment on YouTube ↗
#10
11 ▶ 34:42
What does the snippet output with global value = 1, outer_function setting value = 10, and inner_function setting value = 20?
Live coding Functions, scopes & closures
?
Candidate's answer

Traced all three independent scopes line by line and accurately predicted 10, since value = 20 inside inner_function creates a local binding.

Key takeaway

Under Python's LEGB rule, assignment inside a function binds a new local name by default without modifying enclosing or global bindings.

Open moment on YouTube ↗
#11
12 ▶ 36:35
What is a variable scope, and how does it differ from a namespace?
Live coding Functions, scopes & closures
?
Candidate's answer

Described local variable lifetime and global/nonlocal accurately, but mistakenly concluded that namespace and scope are synonyms.

Key takeaway

A namespace is the concrete mapping from names to objects (like a dict), while a scope is the textual region of code where names from namespaces are resolved unqualified via LEGB.

Open moment on YouTube ↗
#12
13 ▶ 40:00
How can inner_function rebind the immutable 'value' variable defined in enclosing outer_function?
Live coding Functions, scopes & closures
?
Candidate's answer

Contrasted in-place list mutation (.append) with rebinding an immutable int, and immediately wrote 'nonlocal value' followed by 'value = 20'.

Key takeaway

The nonlocal statement binds assignments to the nearest enclosing function scope rather than creating a new local variable.

Open moment on YouTube ↗
#13
14 ▶ 43:05
Code review of the nested function using nonlocal: what readability, design, and style issues does it have?
Live coding Algorithms, code reading & engineering practices
?
Candidate's answer

Flagged poor readability, magic number 10, shadowing 'value' across scopes, and missing if __name__ == '__main__', but missed impure-function side effects and PEP 8 formatting details.

Key takeaway

Mutating outer variables via nonlocal/global introduces hidden side effects; production code favors pure functions with explicit arguments and return values.

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

Pyotr navigates code well, quickly finds solutions and feels confident in technical details. His hard skills are impressive — he knows Python, understands what he's doing, and can solve a non-trivial problem.

But not everything is smooth. Pyotr is easy to throw off: a couple of leading questions — and he's already in doubt. And some basic things, like understanding OOP principles, are not yet fully mastered.

This is a great example of how even strong technical knowledge doesn't always guarantee successful interview performance.

Want to try yourself in this format? Write in the comments and apply!

🔥 Support Pyotr with a like and subscribe if you want more such interviews!

Timestamps:

00:00 Introduction
00:29 A few words about the interviewer and candidate
03:48 Theoretical questions
09:46 Code experiments and questions about them
27:06 Continuation of theoretical questions
34:30 Working with code
54:24 Feedback exchange

On this channel I conduct mock interviews for the role of Python developer for anyone interested. This is a great opportunity to prepare for a real interview, improve your skills, get useful tips and honest feedback. I do all of this absolutely for free. However, maintaining quality requires significant time and resources. If you like my content and want to support the channel, I'll be grateful for any financial support.

https://www.tbank.ru/cf/4PYyn4udS41

#MockInterview #Interview #Python #Backend #Programming