← Back to videos

Junior Python interview: `int` turned out to be trickier than it seems

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Passed interview Level: Junior (strong reasoning with CS fundamentals gaps)

The candidate performed well thanks to structured engineering reasoning: when faced with unfamiliar int(), numeral base, and f-string edge cases, he stayed calm, flagged assumptions explicitly, and formed sound hypotheses. The main growth area is strengthening CS fundamentals around number representation and Python's int internals.

Candidate: Dima
Target role: Junior Python Developer

Studied CS at university and briefly worked as a developer; after a break, studying Python for several months on Yandex Practicum

Answers accuracy 16 total
50% score
Theory
1/7 correct · 50%
Live coding
1/9 correct · 50%
Practical task
Partially solved

Non-obvious int() bases, radix literals, and numeric f-string formatting

Although initially unfamiliar with radix literals (0o12, 0xA), int('12', 8) base conversion, base=0 prefix auto-detection, and f-string modifiers (f'{value=:_}', :x, :b), the candidate methodically tested hypotheses against console output and deduced how each construct works.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Measured, articulate communication and strong consistency across earlier statements
  • + Clear separation between known facts and hypotheses without wild guessing
  • + Ability to analyze live code execution results and refine hypotheses on the fly
  • + Solid conceptual distinction between value equality (==) and object identity (is)

Areas to improve

  • → Review Python int internals (arbitrary-precision integers and small-integer interning)
  • → Revisit numeral systems (0b, 0o, 0x) and why base-8/base-16 map cleanly onto bits and bytes
  • → Read stdlib docs for built-ins like int(x, base=...) and the f-string format specification mini-language
  • → Tighten core terminology (literals, walrus operator :=, low-level vs high-level language criteria)

Questions in this interview

16 / 16
01 ▶ 03:44
What is a numeral system, and how are letters represented in computer memory alongside numbers?
Theory Data types, numbers & memory
?
Candidate's answer

Defined a numeral system as a notation for representing numbers across bases, noting binary storage in hardware and character encoding via numeric codes.

Key takeaway

A numeral system represents numbers using a base and digit set, while all data in memory (characters, colors, media) ultimately maps to binary numbers.

Open moment on YouTube ↗
#01
02 ▶ 05:07
What distinguishes low-level programming languages (Assembly, C) from high-level ones like Python?
Theory Python internals, bytecode & runtime
?
Candidate's answer

Traced the abstraction stack from transistors and CPU instructions through C to Python and noted manual memory management, but conflated language level with age and stdlib richness.

Key takeaway

Language level reflects abstraction over hardware (registers, raw pointers, manual memory vs managed runtime), not standard library size.

Open moment on YouTube ↗
#02
03 ▶ 10:17
Where do developers encounter non-decimal numeral systems in practice, and why do octal and hexadecimal exist?
Theory Data types, numbers & memory
?
Candidate's answer

Cited hexadecimal RGB color codes in HTML/CSS (0–F, 0–255), but admitted he didn't know why bases 8 and 16 were invented alongside binary.

Key takeaway

Octal (2^3) and hex (2^4) compactly group 3 and 4 bits per digit: one byte is always two hex digits (0x00–0xFF), ideal for byte inspection, bitmasks, and Unix permissions.

Open moment on YouTube ↗
#03
04 ▶ 12:43
What is the int type in Python, and is its value range bounded?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly defined int as a whole number without a fractional part, but mistakenly thought Python ints have a fixed overflow limit requiring external libraries for big integers.

Key takeaway

Python 3 int has arbitrary precision with no fixed 32/64-bit overflow; it grows dynamically in memory up to available RAM.

Open moment on YouTube ↗
#04
05 ▶ 15:22
What can you do when numeric data exceeds available RAM, and does storing a number as a string use less memory than int?
Theory Data types, numbers & memory
?
Candidate's answer

Correctly rejected the idea that a string takes less RAM than an int, proposing chunked processing of large values instead.

Key takeaway

Decimal strings waste memory (1 byte per digit vs dense 30-bit limbs in CPython int); memory-constrained code uses binary packing, typed arrays, or streaming.

Open moment on YouTube ↗
#05
06 ▶ 18:22
What rules govern variable names in Python, and what happens if you violate them?
Theory Control flow, loops & syntactic sugar
?
Candidate's answer

Correctly noted identifiers cannot start with a digit and fail before execution, but guessed there is a character-length cap and missed reserved keywords.

Key takeaway

Python identifiers allow letters, digits, and '_' (not starting with a digit, not a reserved keyword, with no length cap); invalid names raise SyntaxError at parse time.

Open moment on YouTube ↗
#06
07 ▶ 19:17
Is int() a function or a method, what inputs does it accept, and how does it work under the hood?
Theory OOP, classes & dunder methods
?
Candidate's answer

Explained that int() converts numeric strings and custom objects via __int__ (raising an error on 'hello'), but mistakenly thought str implements __int__() and built-in str methods can be overridden.

Key takeaway

int is a built-in class: int(x) parses strings directly in its constructor, and for custom objects falls back to __int__(), __index__(), or __trunc__().

Open moment on YouTube ↗
#07
08 ▶ 24:32
What do print(0o12) and print(0xA) output, and is this valid Python syntax?
Live coding Data types, numbers & memory
?
Candidate's answer

Initially guessed an internal constant or easter egg, then after seeing 10 for both snippets deduced that 0o and 0x are octal and hexadecimal literal prefixes.

Key takeaway

Python integer literals support 0b (binary), 0o (octal), and 0x (hex) prefixes; all evaluate to standard int objects printed in base 10 by default.

Open moment on YouTube ↗
#08
09 ▶ 29:35
What type does int(12) return, and does print(int(12)) turn the value itself into a string?
Live coding Data types, numbers & memory
?
Candidate's answer

Correctly noted type(int(12)) is int and print converts objects to strings for stdout, but then conflated terminal text output with a function's return value.

Key takeaway

int(12) evaluates to an int object; print() converts arguments via str() purely to write text to stdout and returns None.

Open moment on YouTube ↗
#09
10 ▶ 31:37
Can you pass two arguments to int(), such as int('12', 8), and what does it return?
Live coding Data types, numbers & memory
?
Candidate's answer

First guessed a tuple ('12', 8), then upon seeing 10 realized the second argument specifies the numeral base of the input string.

Key takeaway

int(string, base) parses a string (or bytes) in the given numeral base from 2 to 36 (plus auto-detect mode base=0) into a Python int.

Open moment on YouTube ↗
#10
11 ▶ 35:47
What does base=0 mean in int('0xff', 0), int('ff', 0), and int('0b1010', 0)?
Live coding Data types, numbers & memory
?
Candidate's answer

Tested hypotheses across binary and hex examples, noticed ValueError on unprefixed 'ff', and deduced that base=0 auto-detects the base from literal prefixes.

Key takeaway

With base=0, int() parses prefixes 0b/0o/0x just like Python integer literals and treats unprefixed digits as base-10 (raising ValueError on bare 'ff').

Open moment on YouTube ↗
#11
12 ▶ 42:33
Is -0 valid for integers in Python, and what does print(0 == -0) output?
Live coding Data types, numbers & memory
?
Candidate's answer

Confidently predicted True, explaining that unary negation on integer zero produces the exact same zero value.

Key takeaway

Python int has no negative zero (-0 is identical to 0); signed -0.0 exists only in IEEE 754 floats, where 0.0 == -0.0 is also True.

Open moment on YouTube ↗
#12
13 ▶ 44:41
Why shouldn't integers be compared with 'is', and what does a = 3; b = 3; a is b evaluate to?
Live coding Data types, numbers & memory
?
Candidate's answer

Clearly distinguished value equality (==) from object identity (is), but predicted False for a = 3; b = 3; a is b, missing CPython's small-integer cache.

Key takeaway

CPython interns small integers in [-5, 256] as implementation optimization, so 3 is 3 is True while larger ints may be False — always compare numbers with ==.

Open moment on YouTube ↗
#13
14 ▶ 46:32
What is a literal in Python, and what is the walrus operator (:=)?
Live coding Python internals, bytecode & runtime
?
Candidate's answer

Honestly admitted forgetting the definition of a literal after using the term, and had not heard of the walrus operator.

Key takeaway

A literal is source-code notation for a fixed constant value (42, 'abc'), while := (PEP 572) binds a variable inside an expression and returns that value.

Open moment on YouTube ↗
#14
15 ▶ 47:04
Is value = 10000000; print(f'{value=:_}') valid Python, and what does =:_ do inside the f-string?
Live coding Strings, encodings & formatting
?
Candidate's answer

Predicted the snippet would run, proposed renaming the variable to 'a' to test his hypothesis, and accurately deduced that '=' prints 'name=' while ':_' groups thousands with underscores.

Key takeaway

In f-strings, trailing '=' outputs 'expr=value' for debugging (Python 3.8+), and the ':_' format specifier adds underscore thousands separators.

Open moment on YouTube ↗
#15
16 ▶ 53:35
What do print(f'{n:x}') and print(f'{n:b}') print for an integer n?
Live coding Strings, encodings & formatting
?
Candidate's answer

Initially expected the variable name to be printed too, then immediately recognized after running that ':x' and ':b' format the integer in hexadecimal and binary.

Key takeaway

Integer format specifiers :b, :o, :d, :x/:X render numbers in binary, octal, decimal, and hex (add '#' as in f'{n:#x}' to include the 0b/0o/0x prefix).

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

A mock interview for the role of Junior Python Developer. We discussed number systems, the `int` type, variable constraints, type casting, how `int()` works, and unusual examples of Python code. The session concluded with a detailed review of the candidate’s answers and feedback on their strengths and areas for improvement.

Timecodes:
00:00 — Start
00:11 — Greetings and introduction of participants
01:32 — How the interview will proceed
03:44 — First question: what is a number system
05:07 — Why are different number systems needed in programming
06:51 — Low-level and high-level languages
10:17 — Where other number systems appear in the code
12:10 — Moving on to Python: what data types does the candidate know
12:43 — What is int
13:10 — Limitations of `int` and working with large numbers
18:22 — Restrictions on variable names
19:17 — The `int()` function and type casting
24:14 — Moving on to coding exercises
31:37 — Can multiple arguments be passed to `int()`
40:41 — Automatic number system detection
42:33 — Comparing integers
44:41 — The difference between == and is
47:04 — New code example: f-strings and number formatting
49:46 — Analysis of number output with digit separation
53:35 — Final example: outputting a number in a different number system
55:25 — Conclusion of the technical section
55:46 — The candidate shares their impressions
58:21 — Detailed feedback from the interviewer