← Back to videos

Junior Python interview: what strings in Python are hiding

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Needs more practice Level: Pre-Junior (hands-on intuition stronger than Python fundamentals)

Not ready for Junior yet due to weak foundational Python theory: although hands-on code reading, backslash escaping fixes, and str.split() behavior were solid, the candidate struggled on core fundamentals (hashing vs list indices, string/bytes literal prefixes, encodings), frequently guessing and flipping his answers instead of stating knowledge boundaries.

Candidate: Artur
Target role: Junior Python Developer

25 y/o · IT lyceum (C++), CS university (C#), 2 years working as a 1C developer, transitioning to Python

Answers accuracy 12 total
50% score
Theory
1/6 correct · 42%
Live coding
1/6 correct · 58%
Practical task
Partially solved

Six literals ('', r'', f'', u'', b'', ''''''), ASCII restriction, backslashes in 'C:\new\', and str.split()

The candidate correctly handled punctuation in strings, fixed 'C:\new\' via escaped backslashes 'C:\\new\\', and nailed ' one two\tthree\nfour '.split() -> ['one', 'two', 'three', 'four']. However, he did not know the r'', u'', and b'' prefixes, initially thought b'abc' had type str rather than bytes, and struggled to define ASCII and literals.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Solid practical intuition on features used in real code (f-strings, fixing backslash escapes, whitespace handling in str.split())
  • + Accurate mental model of string immutability (allocating a new object on change) and __hash__ / __eq__
  • + Honest admission when seeing unfamiliar literal prefixes (r, u, b) in the code section
  • + Engaged dialogue and willingness to reason through edge cases interactively

Areas to improve

  • → Systematically study Python's language fundamentals instead of piecing together assumptions from C++, C#, and 1C
  • → Learn how hash functions and hash tables actually work (distinguishing O(1) hash-bucket lookup from list positional indices)
  • → Master Python string/bytes literals (plain, f'', raw r'', bytes b'', triple-quoted strings and __doc__), ASCII vs UTF-8 encodings, and escape sequences
  • → State 'I don't know' directly instead of improvising shaky explanations that invite deeper contradictions

Questions in this interview

12 / 12
01 ▶ 04:02
What is a data type in Python, and which built-in types are mutable vs immutable?
Theory Data types, numbers & memory
?
Candidate's answer

Defined a data type as a class and placed int, str, tuple in immutable and list in mutable, but contradicted himself by listing set in both categories and omitted dict and frozenset.

Key takeaway

Core immutable types in Python are int, float, bool, str, bytes, tuple, and frozenset; core mutable types are list, dict, set, and bytearray.

Open moment on YouTube ↗
#01
02 ▶ 05:14
What does string immutability mean if you can always reassign a variable to a new string?
Theory Data types, numbers & memory
?
Candidate's answer

Clearly explained that modifying a string allocates a brand-new object in memory while the original stays unchanged with a fixed hash (__hash__ and equality dunders).

Key takeaway

Rebinding s = s + '!' points the variable name to a new str object; mutating an existing str in place (s[0] = 'x') raises TypeError.

Open moment on YouTube ↗
#02
03 ▶ 06:07
What is an object's hash, and how does it speed up lookup compared to searching a list?
Theory Collections, lists, dicts & hash tables
?
Candidate's answer

Called a hash an 'immutable memory index' and got bogged down comparing shifted list indices with library card catalogs instead of explaining hash-function calculation.

Key takeaway

Lists give O(1) lookup by numeric position but O(n) search by value, whereas a hash function computes a bucket offset directly from the value itself in O(1) average time.

Open moment on YouTube ↗
#03
04 ▶ 17:24
How can strings be declared in Python, and how do single, double, and triple quotes differ?
Theory Strings, encodings & formatting
?
Candidate's answer

Named str(), single and double quotes (noting quote nesting convenience), and f-strings, but initially claimed triple quotes are not regular strings and confused __doc__ with __name__.

Key takeaway

Single, double, and triple quotes all produce plain str instances; triple quotes allow multi-line text and populate __doc__ when placed as the first statement of a module, class, or function.

Open moment on YouTube ↗
#04
05 ▶ 21:51
Which characters require escaping inside a standard Python string literal?
Theory Strings, encodings & formatting
?
Candidate's answer

Misspoke 'concatenate' for 'escape' and wrongly claimed characters like *, %, and regex metacharacters cannot appear unescaped in ordinary Python strings.

Key takeaway

Inside normal Python string literals, only backslash \ and the matching delimiter quote have special lexical meaning; regex metacharacters like * and + are ordinary characters.

Open moment on YouTube ↗
#05
06 ▶ 24:46
What is a regular expression, and is it a string in Python?
Theory Strings, encodings & formatting
?
Candidate's answer

Described regexes conceptually as patterns for matching text, but wavered between calling a regex a substring, a string, or a str subclass.

Key takeaway

A regex pattern is written as a str (typically a raw string r'\d+') and compiled by Python's re module into an re.Pattern object.

Open moment on YouTube ↗
#06
07 ▶ 27:28
Will a string containing characters like * and + without backslashes fail, and why do we need escape sequences at all?
Live coding Strings, encodings & formatting
?
Candidate's answer

Correctly predicted no error on asterisks, then swung to the opposite extreme claiming any keyboard character works unescaped in single-line strings and \n is purely cosmetic.

Key takeaway

Unescaped matching quotes, trailing backslashes, literal newlines in single-quoted strings, and non-printable control characters require escape sequences.

Open moment on YouTube ↗
#07
08 ▶ 32:25
What do the six literal forms 'abc', r'abc', f'abc', u'abc', b'abc', and '''abc''' mean in Python?
Live coding Strings, encodings & formatting
?
Candidate's answer

Explained plain 'abc', f-string interpolation, and triple-quoted '''abc''', admitted not knowing r, u, and b, and misread the printed b'abc' repr as quote formatting.

Key takeaway

'abc' and legacy u'abc' are Unicode str, r'abc' is a raw str disabling backslash escapes, f'abc' interpolates expressions, '''abc''' spans lines, and b'abc' creates a bytes object.

Open moment on YouTube ↗
#08
09 ▶ 41:07
Which of the six literals fails when 'abc' is replaced with Cyrillic 'абв', and what do ASCII and 'literal' mean?
Live coding Strings, encodings & formatting
?
Candidate's answer

Vouched for plain, f-, and triple-quoted strings, saw b'абв' fail due to ASCII restrictions, and recalled character code tables lacking Cyrillic, while mislabeling ASCII as 'formatting' and missing the definition of a literal.

Key takeaway

A literal is source-code notation for a fixed value; bytes literals b'...' only accept 7-bit ASCII characters (0..127), so non-ASCII text must be encoded via 'абв'.encode('utf-8').

Open moment on YouTube ↗
#09
10 ▶ 47:16
Why does 'C:\new\' fail with SyntaxError, and how do you print the literal path C:\new\ on one line?
Live coding Strings, encodings & formatting
?
Candidate's answer

Caught \n acting as a newline inside '\new' and fixed the string to 'C:\\new\\' so it printed cleanly on one line, though he missed that the trailing \ specifically escaped the closing quote.

Key takeaway

In 'C:\new\', \n becomes a newline and the final \ escapes the closing quote causing an unterminated string literal (even raw strings r'...' cannot end with an odd number of backslashes).

Open moment on YouTube ↗
#10
11 ▶ 57:13
Does type() return str for all six literals, including b'abc'?
Live coding Data types, numbers & memory
?
Candidate's answer

Noticed b'abc' printed differently, initially leaned toward all six still being strings, and then identified <class 'bytes'> as a distinct byte sequence type once shown type().

Key takeaway

Python 3 strictly separates text strings (str, sequences of Unicode code points) from binary data (bytes, immutable sequences of integers 0..255).

Open moment on YouTube ↗
#11
12 ▶ 59:25
What does calling ' one two\tthree\nfour '.split() with no arguments return?
Live coding Strings, encodings & formatting
?
Candidate's answer

Once reminded of the method name split(), accurately predicted stripping leading/trailing whitespace, collapsing consecutive spaces, \t, and \n, and returning ['one', 'two', 'three', 'four'].

Key takeaway

s.split() (sep=None) strips leading/trailing whitespace and splits on arbitrary runs of any whitespace characters, unlike s.split(' ') which splits strictly on each single space and keeps empty strings.

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

A mock interview for the role of Junior Python Developer. This episode takes an in-depth look at strings in Python: mutability and immutability, ways to declare strings, escaping, special characters, different string literals, `split()`, and common mistakes in interview reasoning. Finally, there is detailed feedback on the candidate’s strengths and areas for improvement.

Timecodes:
00:00 — Start
00:11 — Greeting and introduction of participants
02:10 — How the interview will proceed
04:02 — First question: what is a data type
04:36 — Mutable and immutable data types
06:07 — What is a hash
16:19 — Moving on to strings in Python
17:24 — How to declare a string in Python
21:51 — Are there any restrictions when creating strings
22:16 — Escaping special characters
24:46 — What is a regular expression
27:16 — Moving on to code analysis
27:28 — Can you create a string with special characters without escaping
32:25 — Analysis of different string literals in Python
35:54 — Why are there so many ways to define strings in Python
41:07 — Checking strings with Russian characters
42:12 — ASCII and the limitations of certain literals
44:31 — What is a literal
47:16 — Analysing strings with backslashes
57:13 — Are all the options discussed strings
59:25 — How to split a long string into parts
59:42 — The split() method
01:04:26 — Moving on to feedback
01:04:51 — The candidate’s impressions of the interview
01:06:26 — Detailed feedback from the interviewer