← Back to videos

A Python interview that made the candidate doubt their knowledge

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Pre-Junior / early Junior (fragmented practical knowledge without systematic fundamentals)

Not ready yet to pass a Junior Python interview confidently: despite articulate communication and prior project work, the candidate's knowledge is fragmented and unsystematic, with notable gaps in core terminology (terminal vs shell, stdio streams, function vs method, eval vs exec), short-circuit boolean return values, and terminal ANSI escape handling.

Candidate: Vlad
Target role: Junior Python Developer

Informal project experience (building an LMS through acquaintances without technical interviews), testing readiness for formal Junior roles

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

Short-circuit 'user and admin or "guest"' and terminal output overwriting via ANSI escapes

The candidate grasped the high-level goal and tuple unpacking, but after seeing both users printed as 'admin' he misanalyzed return user and admin or 'guest' (claiming it always returns True) and failed to recognize the ANSI escape sequences (\033[...]) in the f-string that repositioned the terminal cursor to overwrite the printed status.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Clear, composed communication and steady engagement without panicking when challenged
  • + Practical hands-on familiarity with Linux servers and preferring structured logging over print in production
  • + Awareness of code-injection security risks when passing untrusted strings to eval()
  • + Sensible code-review critique favoring explicit ternary expressions and self-documenting code over clever boolean tricks

Areas to improve

  • → Systematize core developer terminology: terminal vs console vs shell (bash/zsh) and standard streams (stdin, stdout, stderr)
  • → Clarify Python's object model: why built-in callables like print and eval are functions rather than bound methods despite inheriting from object
  • → Master short-circuit boolean operators 'and' and 'or', which return actual operand objects rather than coercing to bool
  • → Understand the boundary between Python's print() writing characters to stdout and the terminal emulator interpreting ANSI escape sequences (\033[...])

Questions in this interview

12 / 12
01 ▶ 03:21
What are a terminal, a console, and a command line, and how do they differ?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Described the terminal as a text interface for controlling a machine without a GUI (deploying apps, editing server files), but treated terminal, console, and command line as exact synonyms.

Key takeaway

A terminal emulator handles character display and input, whereas a command-line shell (bash, zsh, PowerShell) is the program running inside it that parses and executes commands.

Open moment on YouTube ↗
#01
02 ▶ 07:31
What is a command-line shell when working in a terminal, and can you name examples?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Confused a command shell with a desktop GUI or terminal styling add-ons and claimed he had never used a shell.

Key takeaway

Every interactive terminal session runs a shell (bash, zsh, PowerShell) that interprets commands, environment variables, pipes, and stream redirections.

Open moment on YouTube ↗
#02
03 ▶ 08:50
What are the standard I/O streams in Python?
Theory Modules, packages, imports & stdlib
?
Candidate's answer

Initially confused I/O streams with multithreading and the GIL, admitting he did not know standard stream terminology before vaguely recalling the name stdout.

Key takeaway

Every OS process gets three standard streams — stdin (0), stdout (1), and stderr (2) — exposed in Python as file-like objects in the sys module.

Open moment on YouTube ↗
#03
04 ▶ 10:30
How does built-in print() work under the hood, what is stdout, and what parameters does print() accept?
Theory Modules, packages, imports & stdlib
?
Candidate's answer

Correctly mentioned string conversion and the default end='\n' parameter, but mischaracterized stdout as a C function and missed sep, file, and flush.

Key takeaway

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) formats arguments via str() and writes them to the target text stream.

Open moment on YouTube ↗
#04
05 ▶ 15:18
What controls text color when calling print(), and can print() colorize text or clear the terminal screen?
Theory Strings, encodings & formatting
?
Candidate's answer

Guessed print has color attributes or requires modules like pprint, and thought print() cannot clear the terminal screen, suggesting eval() instead.

Key takeaway

print() merely writes characters to stdout; the terminal emulator changes colors, moves the cursor, or clears the screen when it parses ANSI escape codes like '\033[31m' or '\033[2J'.

Open moment on YouTube ↗
#05
06 ▶ 17:51
What does eval() do, and is it a function or a method in Python?
Theory OOP, classes & dunder methods
?
Candidate's answer

Accurately explained that eval() evaluates a string expression and poses injection risks, but talked himself into calling eval() a method because everything inherits from object.

Key takeaway

eval() and print() are built-in functions in the builtins namespace; inheriting from object makes a function a first-class object, not a class method.

Open moment on YouTube ↗
#06
07 ▶ 21:33
What is the difference between built-in eval() and exec()?
Theory Python internals, bytecode & runtime
?
Candidate's answer

Admitted he had only used eval(), guessing from the names that eval computes an expression while exec executes broader code, though he reversed which one returns a value.

Key takeaway

eval() evaluates a single expression and returns its value, whereas exec() executes arbitrary multi-line statements for their side effects and always returns None.

Open moment on YouTube ↗
#07
08 ▶ 23:20
Why is cramming complex logic into an unreadable one-liner bad practice if the machine runs it fine and AI can explain it?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Cited 'Explicit is better than implicit' and argued that humans maintain and debug code over time, whereas relying on AI to decipher cryptic code slows work down and introduces errors.

Key takeaway

Code is read and modified far more often than it is written; clear structure and naming directly reduce bug rates and maintenance cost.

Open moment on YouTube ↗
#08
09 ▶ 25:47
What does def status(user, admin): return user and admin or 'guest' return for ('root', True) and ('Vlad', False)?
Live coding Control flow, loops & syntactic sugar
?
Candidate's answer

Initially guessed True and 'guest' correctly, then abandoned that answer after seeing the terminal output and insisted that user and admin or 'guest' always evaluates to boolean True.

Key takeaway

Python's 'and' binds tighter than 'or' and both return actual operand values without casting to bool: ('root' and True) or 'guest' -> True, while ('Vlad' and False) or 'guest' -> 'guest'.

Open moment on YouTube ↗
#09
10 ▶ 39:00
What is Python's ternary conditional expression and how does it differ from the 'and / or' idiom?
Live coding Control flow, loops & syntactic sugar
?
Candidate's answer

Explained single-line conditional expressions (x if cond else y) for selecting between two values and noted they are far clearer than the old and/or trick.

Key takeaway

The legacy cond and a or b idiom breaks whenever 'a' itself is falsy (returning 'b' instead); 'a if cond else b' is both bug-free and explicit.

Open moment on YouTube ↗
#10
11 ▶ 40:35
Why did the final print(f'...') containing \033[...] and len(name) + 2 display 'admin' for both users?
Live coding Strings, encodings & formatting
?
Candidate's answer

Looked for a hidden conditional inside the f-string and did not recognize the \033[...] ANSI cursor-control sequences overwriting the printed {s} value in the terminal.

Key takeaway

ANSI cursor-movement sequences like \033[<N>G reposition the terminal cursor on the current line, overwriting previously printed characters (the mechanism behind CLI progress bars).

Open moment on YouTube ↗
#11
12 ▶ 42:56
What readability and style issues would you flag in this snippet during code review?
Live coding Algorithms, code reading & engineering practices
?
Candidate's answer

Rightly criticized the cryptic and/or return expression (recommending an explicit if/ternary), the unreadable f-string, and suggested clearer naming or data structures for user records.

Key takeaway

Clean functions return consistent types ('admin' if user and is_admin else 'guest') and keep terminal formatting separate from business logic.

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

At first glance, the questions seem straightforward: the terminal, `print()`, `eval()`, `exec()`, logical operators, a short code snippet…
But it is precisely these topics that most often reveal whether a developer truly understands Python or has simply memorised the answers to common questions.
In this mock interview, we examine fundamental topics in detail, discuss how Python works, analyse the code and, finally, discuss the candidate’s strengths, their mistakes and a plan for further development.

This video will be useful for:
- Junior Python developers;
- those preparing for a technical interview;
- anyone who wants to gain a deeper understanding of Python, rather than simply memorising answers.

If you’d like to test yourself, try answering the questions before the candidate does.

Timecodes

00:00 Start
00:33 Introduction
03:21 What are a terminal, a console and a command line?
08:50 Standard streams in Python
10:30 Breaking down the print() function
17:51 What eval() does and how it differs from exec()
25:35 Practical exercise with code
45:15 The candidate’s impressions
47:40 Detailed feedback