A junior Python interview has three predictable parts: a basics screen, a coding round, and a behavioral chat. The first two are where 80% of candidates get filtered. This guide gives you 30 curated questions across both, each with a short answer, working code where it helps, and the common wrong answer interviewers use as a trap. Pair it with our complete guide on learning Python for a career if you're still building the skills behind the answers.
Key Takeaways
A junior Python screen averages 45-60 minutes and covers 6-10 questions across basics, data structures, and one live-code task. Prepare to answer in under 90 seconds each.
Per the Stack Overflow Developer Survey 2024, Python is the most popular language for people learning to code, which means the interviewer has seen thousands of junior candidates, so clarity wins (Stack Overflow, 2024).
Easy-level LeetCode is enough for most non-FAANG junior screens; medium-level shows up at larger product companies.
The trap on every conceptual question is verbosity: short, direct answers score higher than long ones, even when both are correct.
Five live-code patterns cover ~70% of junior coding rounds: reverse a string, count frequencies, find duplicates, FizzBuzz with a twist, and anagram check.
45-60
minutes for a junior screen
6-10
questions in a typical round
~90s
target answer length
5
live-code patterns cover most rounds
How Does a Junior Python Interview Actually Work?
A junior Python interview typically runs 45-60 minutes and has three parts. First, a basics screen of rapid-fire conceptual questions, where the interviewer is testing fluency, not depth. Second, a live-code round of one or two tasks on a shared editor, where they watch how you think while coding. Third, a behavioral section, where they probe how you handle disagreement, debugging, and learning new code.
Most candidates fail on the first part by giving long, hedged answers. The interviewer needs to fit 6-10 questions into 20 minutes, so a 30-second clean answer scores higher than a 2-minute one. Answer the question first, then offer one detail of color, then stop. If they want more, they'll ask.
The frequency of question topics varies by company type. Data shops emphasize Pandas and NumPy. Web shops emphasize Flask, Django, or FastAPI. Embedded or DevOps shops emphasize standard library, file I/O, and subprocess. The 30 questions below cover the universal core; the company-specific layer goes on top.
Source: CodeGym alumni interview survey, n=412 junior Python interviews, 2023-2025.
Which Basic Python Concepts Show Up Most? (8 Questions)
These are the rapid-fire screen. The interviewer is checking that you can explain core ideas in your own words, not recite a tutorial. Aim for one to three sentences per answer.
1. What's the difference between a list and a tuple?
A list is mutable and uses square brackets. A tuple is immutable and uses parentheses. Tuples are slightly faster, hashable when their contents are hashable, and can serve as dictionary keys. Use lists for collections that change; use tuples for fixed records like coordinates or grouped return values.
Trap: saying tuples are "always faster than lists." The speed difference is marginal and only matters in tight loops. Don't oversell it.
2. What is the difference between is and ==?
The == operator compares values. The is operator compares identity, meaning whether two references point to the same object in memory. Use == for normal value checks and reserve is for None, True, and False per PEP 8 guidance (PEP 8, Programming Recommendations).
Trap: claiming a is b always equals a == b for short strings. Python's integer and string caching makes that look true for small values but it isn't a language guarantee.
3. Explain mutable vs immutable types with examples.
Mutable objects can change in place after creation: lists, dicts, sets. Immutable objects cannot: strings, tuples, frozensets, integers, floats, booleans. When you "modify" an immutable, Python actually creates a new object and rebinds the name. This matters for function arguments. Mutables passed in can be modified by the function; immutables can't.
4. What is PEP 8 and why does it matter?
PEP 8 is the Python style guide that defines naming, indentation, line length, and whitespace conventions (python.org, PEP 8). It matters because Python is read more often than it's written, and consistent style cuts the cognitive cost of reading another person's code. Most teams enforce it through automated tools like black, ruff, or flake8.
5. What is the GIL and how does it affect performance?
The Global Interpreter Lock is a mutex in CPython that allows only one thread to execute Python bytecode at a time. It simplifies memory management but means threading does not parallelize CPU-bound work. For CPU-bound tasks, use multiprocessing or NumPy. For I/O-bound tasks like API calls or file reads, threading and asyncio still work because they release the GIL while waiting.
Trap: saying "Python can't do multithreading." It can, just not for CPU-bound parallelism in CPython. Concurrency for I/O is fine.
6. Explain *args and **kwargs.
*args packs extra positional arguments into a tuple. **kwargs packs extra keyword arguments into a dict. The names args and kwargs are conventions; only the * and ** matter to Python. They're useful when you wrap or proxy another function and want to forward whatever the caller passes without listing each parameter.
A list comprehension is a compact way to build a list from an iterable, optionally filtering. They're idiomatic Python and faster than equivalent for-loops in most cases. Use them when the expression stays readable; once nesting or conditions stack, switch back to a regular loop.
squares_of_evens = [n * n for n in range(20) if n % 2 == 0]
# [0, 4, 16, 36, 64, 100, 144, 196, 256, 324]
8. How does Python handle memory management?
Python uses reference counting as the primary mechanism, supported by a cyclic garbage collector for objects that reference each other. When an object's reference count drops to zero, it's freed immediately. The garbage collector handles cycles that reference counting can't detect, like a list that contains itself. You rarely manage memory manually, but knowing this helps with debugging memory leaks.
Which Data Structure Questions Should You Expect? (6 Questions)
This section is where many candidates trip on the "obvious" answer. The interviewer is checking whether you know the standard library well enough to skip writing custom code for things Python already does.
9. How would you remove duplicates from a list?
The shortest correct answer is list(set(items)), with the caveat that it doesn't preserve order. If order matters, use list(dict.fromkeys(items)), which has preserved insertion order since Python 3.7 (python.org, dict.fromkeys). For lists of unhashable items like dicts, you need a loop with a seen-set of identifying keys.
10. What's the difference between a dict and a set?
A dict stores key-value pairs; a set stores unique values without associated values. Both use hash tables under the hood, both require hashable keys, and both deliver average O(1) lookup. Use a dict when you need to map a key to a value; use a set when you only care about membership or uniqueness.
11. How does dictionary lookup achieve O(1) on average?
Python computes the key's hash, maps it to a bucket index in an internal array, and reads the value from that bucket. Hashing is constant time for fixed-size keys, so the lookup is O(1) on average. Worst case is O(n) when many keys hash to the same bucket, but Python's hash function and bucket resizing keep that rare in practice.
12. Explain shallow vs deep copy.
A shallow copy duplicates the outer container but shares references to inner objects. A deep copy recursively duplicates everything. For a list of lists, a shallow copy lets you modify the outer list independently but inner-list edits leak into both copies. Use copy.copy for shallow and copy.deepcopy for deep. Prefer shallow unless you specifically need isolation of nested mutables.
import copy
a = [[1, 2], [3, 4]]
shallow = copy.copy(a)
deep = copy.deepcopy(a)
a[0].append(99)
# shallow[0] is now [1, 2, 99]
# deep[0] is still [1, 2]
13. What's the difference between append(), extend(), and insert()?
append(x) adds x as a single element at the end. extend(iterable) adds each element of an iterable at the end. insert(i, x) places x at index i, shifting later elements right (O(n) for the shift). Junior bug: using append with a list expecting flat extension, which leaves you with a nested list.
14. How do you sort a list of dicts by a key?
Use sorted(items, key=lambda d: d["age"]), or pass operator.itemgetter("age") for slightly faster and more readable code. Add reverse=True for descending order. For multiple sort keys, return a tuple from the key function: key=lambda d: (d["dept"], d["age"]).
What Control Flow, Function, and OOP Questions Come Up? (8 Questions)
This is where seniors look for "do you actually write Python?" signal. Answers should sound natural, not memorized.
15. What does if __name__ == "__main__": do?
It runs the indented block only when the script is executed directly, not when imported as a module. The __name__ variable equals "__main__" for the entry-point script and the module's name when imported. The pattern lets the same file serve as both an importable library and a runnable command without side effects on import.
16. Explain decorators in 60 seconds.
A decorator is a function that takes a function and returns a modified version of it. The @decorator syntax is sugar for func = decorator(func). Common uses: logging, timing, caching with functools.lru_cache, route registration in Flask. The key skill is reading the syntax and not panicking; it's just function composition with friendly syntax.
17. What's a generator and when would you use one?
A generator is a function with yield; calling it returns an iterator that produces values lazily, one at a time. They're memory-efficient because nothing is materialized in full. Use them for streaming large files line by line, infinite sequences, or pipeline-style data processing. The trade-off is you can iterate only once.
def read_lines(path):
with open(path) as f:
for line in f:
yield line.rstrip()
# Memory usage stays flat even for a 10 GB file
18. Difference between class methods, static methods, and instance methods.
An instance method takes self and operates on a specific instance. A class method takes cls, marked with @classmethod, and operates on the class itself, which is useful for alternative constructors. A static method, marked with @staticmethod, takes neither. It's a function namespaced under the class, used when a helper logically belongs to the class but doesn't touch state.
19. What is inheritance and how does Python handle multiple inheritance?
Inheritance lets a class reuse and extend another class. Python supports multiple inheritance and resolves method calls via the Method Resolution Order, computed using the C3 linearization algorithm (python.org, MRO). In practice, composition is usually safer than deep multiple inheritance. Favor mixins with a single responsibility when you do reach for it.
Trap: claiming Python uses depth-first inheritance like old Python 2. Modern Python uses C3 linearization, which is closer to a topological sort.
20. What are * and / in function signatures (positional/keyword-only args)?
Anything before / is positional-only and cannot be passed by name. Anything after * is keyword-only and must be passed by name. Together they let an API author enforce calling conventions and protect names from being treated as part of the public contract. Useful when you might rename parameters later.
21. Explain context managers and the with statement.
A context manager is an object with __enter__ and __exit__ methods; the with statement uses them to acquire and release a resource cleanly even when exceptions occur. The classic example is file I/O, where with open(path) as f: guarantees the file closes. You can build your own with contextlib.contextmanager for short cases or a class for stateful ones.
22. What's the difference between __init__ and __new__?
__new__ creates a new instance and returns it; __init__ initializes the instance after creation. You almost never override __new__ in normal Python. The exception is when subclassing immutable types like tuple or str, or when implementing the singleton pattern. For typical classes, just write __init__.
Which Live-Code Patterns Appear Most? (5 Tasks)
For each task: describe your approach out loud before typing, name the time and space complexity, and add a quick sanity-check call at the end. Interviewers grade the process at least as much as the final code.
23. Reverse a string (and discuss 3 approaches).
Three working approaches, ranked by what interviewers want to see: slicing for the idiomatic Python answer, reversed with join for the iterator-friendly answer, and a manual loop for the algorithm-fundamentals answer. Mentioning all three signals that you understand idioms and underlying mechanics.
The interviewer wants to see you reach for collections.Counter, the standard-library tool for this exact job. Writing a manual dict-and-counter is correct but signals you don't know the standard library.
from collections import Counter
def word_frequency(text: str) -> dict[str, int]:
words = text.lower().split()
return dict(Counter(words))
word_frequency("the cat sat on the mat")
# {'the': 2, 'cat': 1, 'sat': 1, 'on': 1, 'mat': 1}
25. Find duplicates in a list (O(n) solution).
One pass through the list, tracking what you've seen in a set. Two ways to phrase the output: return the list of duplicates, or return the count of each. Confirm with the interviewer which they want before coding.
def find_duplicates(items: list) -> list:
seen, duplicates = set(), set()
for item in items:
if item in seen:
duplicates.add(item)
else:
seen.add(item)
return list(duplicates)
find_duplicates([1, 2, 2, 3, 4, 4, 5]) # [2, 4]
26. FizzBuzz with a twist (extend it for new conditions cleanly).
The interviewer isn't asking whether you can write FizzBuzz. They're asking whether you can write it so adding a new rule (like "Bazz" for multiples of 7) takes one line, not five. Use a list of rules and iterate over it; that's the structure that scales.
RULES = [(3, "Fizz"), (5, "Buzz"), (7, "Bazz")]
def fizzbuzz(n: int) -> str:
out = "".join(word for divisor, word in RULES if n % divisor == 0)
return out or str(n)
for i in range(1, 21):
print(fizzbuzz(i))
# Adding (11, "Fuzz") is a one-line change.
27. Check if two strings are anagrams.
Two clean approaches: sort and compare, or count and compare. Sort is O(n log n); count is O(n). Both score full points if you mention the trade-off. Strip whitespace and lowercase first if the spec is loose about it, and ask before you assume.
from collections import Counter
def is_anagram(a: str, b: str) -> bool:
a = a.replace(" ", "").lower()
b = b.replace(" ", "").lower()
return Counter(a) == Counter(b)
assert is_anagram("listen", "silent")
assert is_anagram("Conversation", "Voices rant on")
assert not is_anagram("hello", "world")
What Library and Tooling Questions Should You Prepare? (3 Questions)
28. What is pip and what's a virtual environment?
pip is Python's standard package installer. A virtual environment is an isolated Python install, with its own interpreter and its own site-packages folder, created so one project's dependencies don't collide with another's. Modern Python ships venv in the standard library; many teams now use uv or poetry for faster, lockfile-driven setups.
# Standard venv
python -m venv .venv
source .venv/bin/activate # macOS / Linux
.venv\Scripts\activate # Windows
pip install -r requirements.txt
29. Which Python web frameworks have you used? Flask vs Django vs FastAPI.
Three popular choices, each with a clear niche. Django is a batteries-included framework for full-feature web apps with built-in ORM, admin, and auth. Flask is minimalist and great for small services or learning. FastAPI is async-first with built-in OpenAPI docs and Pydantic validation, which makes it a popular pick for new APIs in 2026.
If you've only built toy projects, say so honestly and pick the one you understand best. Interviewers respect "I built two CRUD apps in Flask and would read the Django docs before claiming production knowledge" more than vague name-dropping.
30. Have you used pytest? Write a test for an add(a, b) function.
Showing the framework's idioms matters more than testing every edge case. Aim for clear arrange-act-assert structure, one obvious case, one edge case, and one parametrize block to signal you know the framework beyond assert.
Where Does Python Come Up in Behavioral Questions?
The behavioral round still touches Python through three predictable angles: a project you built, a bug you debugged, and a code disagreement you handled. The interviewer is testing whether you can talk about your work clearly, not whether your story is impressive.
Use the STAR format: Situation (one sentence of context), Task (what you needed to do), Action (the steps you took), Result (the outcome and what you learned). Keep each part to 20-40 seconds. The most common mistake is dumping every detail of the Situation, which burns the time you needed for Action and Result.
One concrete prep tip: pick three projects from your portfolio and write a STAR paragraph for each, then practice them out loud until they fit in 90 seconds. Cite the Python-specific decisions you made: chose Flask over Django because the app was small, used a generator because the file was 4 GB. Interviewers retain decisions better than features.
Build a Portfolio Worth Talking About in Interviews
The CodeGym Python Course teaches by doing, with 800+ practical tasks across 62 levels, an AI validator that checks every solution, and an AI mentor that explains where you're stuck. The Algorithms and Python Pro modules give you the live-code reflexes interviewers test. First level is free; the full Python track is on the pricing page.
Start the free Python track →
How Should You Prepare for a Python Interview in Two Weeks?
Two weeks of focused prep is enough to walk into a junior screen comfortable, assuming you already know basic Python syntax. The plan below is what works for most CodeGym alumni who land their first job within a month of their first interview.
Day
Focus
Output by end of day
Days 1-2
Re-read PEP 8 + Python docs on lists, dicts, sets, tuples
Re-explain each concept out loud in 60 seconds
Days 3-4
Answer all 30 questions from this page out loud, timed
Each answer under 90 seconds, no notes
Days 5-7
5 LeetCode easies per day, focus on string + list patterns
15 problems solved, each under 25 minutes
Days 8-10
Mock interview with a friend or recording yourself
3 full mocks completed, weakest topic noted
Days 11-13
Build or polish one portfolio project; write a STAR paragraph
One project deployable + 3 STAR stories ready
Day 14
Rest, light review, sleep early
Calm, fed, well-rested for the real interview
The two underrated moves on this plan are the daily out-loud practice and the mock interview recording. Most candidates only practice silently in their head, which feels productive but doesn't build the muscle of speaking technical content under mild pressure. Recording yourself is uncomfortable for the first five minutes; after that, it's the highest-yield prep activity on the list.
For the portfolio piece, see our 25 Python projects for beginners if you don't already have something to talk about. And once you've landed an interview round, Python developer salary in 2026 covers what to expect on the offer side.
Frequently Asked Questions
What level of LeetCode is expected for a junior Python role?
For most junior Python roles outside FAANG, easy-level LeetCode is enough. Expect string manipulation, list operations, dictionary use, and basic loops. Medium-level appears for product roles at larger companies. FAANG junior interviews go deeper, with mediums on trees, graphs, and binary search. Solve 30-50 easies and you're prepared for the typical screen.
Should I memorize syntax or focus on concepts?
Concepts matter more, but enough syntax for fluent live coding is non-negotiable. Interviewers tolerate Googling a method name; they don't tolerate a candidate who can't write a for-loop without thinking. Aim for fluent muscle memory on collection methods, comprehensions, slicing, and dict operations. Beyond that, focus on explaining the why, the trade-offs, and how you'd test the code.
How do I handle a question I can't answer?
Say so honestly, then think out loud. The interviewer wants to see your reasoning process more than a perfect answer. Try: "I haven't used that in production, but my best guess is X because Y, and I'd verify it by reading the docs." Honesty plus structured guessing scores far higher than silence or fabrication, which interviewers usually catch.
Are take-home assignments standard for Python junior roles?
Common at startups and mid-sized companies; rare at FAANG. A typical take-home asks for a small CLI or web service in 2-6 hours, returned within a week. Treat it as a portfolio piece: include a README, tests, and a short note on trade-offs you made. Spending 30 minutes longer to polish doubles your chance of passing to the next round.
The Bottom Line: Junior Python Interviews Reward Clarity, Not Cleverness
Junior Python interviews are not designed to trick you. They're designed to find candidates who can explain ideas clearly, write working code under mild pressure, and learn fast on the job. Master the 30 questions above and you'll match the prep level of the candidates who pass. For the wider career roadmap, from your first line of Python to your first paycheck, start with our complete guide on learning Python for a career.
GO TO FULL VERSION