Python Developer Interview Questions and Answers, With Practical Exercises and a Scoring Rubric

joseph cole

Updated on March 2, 2023

Python Developer Interview Questions and Answers, With Practical Exercises and a Scoring Rubric

joseph cole

Updated on March 2, 2023

In this post

CREATE YOUR ACCOUNT

Accelerate the hiring of top talent

Make talent quality your leading analytic with skills-based hiring solution.

Get started

Python is easy to read, which makes it easy to fake in an interview. A candidate can describe list comprehensions fluently and still write code that loads a 4 GB file into memory or breaks because of a default argument. The questions below are built to surface that gap. Each one comes with what a strong answer includes, and the exercises show how candidates write code when nobody is prompting them.

Use this guide for the technical interview stage, after a skills screen has confirmed the basics.

What a Python developer does

Python developers write server side logic for web applications, build APIs, connect data sources and automate workflows, often with frameworks such as Django and Flask. Python is free and open source, runs across platforms and supports object oriented, functional and procedural styles, which is why it shows up in web development, data engineering and machine learning teams alike.

Qualifications: usually a bachelor’s degree in computer science or equivalent experience.

Skills to look for:

  • Server side web logic and at least one Python web framework
  • ORM libraries and integration of multiple data sources
  • Basic front end knowledge: HTML5, CSS3 and JavaScript
  • Unit and functional testing, debugging and profiling
  • Readable, idiomatic code

Screen before you interview

An hour long interview is an expensive way to find out a candidate can’t write a loop. Glider’s technical skill tests and coding simulations check Python skills before the interview, including Jupyter Notebook tasks for data roles, with AI proctoring so you know the work is the candidate’s own.

How to score Python interview answers

ScoreLevelWhat you hear
1RecallA definition with no example
2ExplainsCorrect reasoning about how it works
3AppliesWorking code or a concrete example from their own projects
4JudgesTradeoffs, edge cases, performance and when not to use it

Expect mid level developers to average 3 and senior developers to reach 4 on design and performance questions.

Core Python developer interview questions

1. How are arguments passed in Python? By reference or by value?

Strong answer: neither label fits exactly. Python passes object references by value, sometimes called pass by assignment. Mutating a list inside a function changes the caller’s list; rebinding the name inside the function does not.

Red flag: “Everything is by reference.”

2. Why are functions called first class objects in Python?

Strong answer: functions can be assigned to variables, passed as arguments, returned from other functions and stored in data structures. That’s what makes decorators and callbacks possible. A score of 3 includes a decorator they’ve written.

3. What does it mean when a lambda expression forms a closure?

Strong answer: the lambda captures variables from its enclosing scope and keeps access to them after that scope ends. Strong candidates mention late binding: lambdas created in a loop all see the loop variable’s final value unless it’s bound as a default argument.

4. What do you know about list and dict comprehensions?

Strong answer: concise syntax for building lists and dicts from iterables, with optional filters. A score of 4 adds when to switch to a generator expression to avoid building a large list in memory, and when a plain loop reads better.

5. What is the key difference between a tuple and a list?

Strong answer: tuples are immutable, lists are mutable. Because of that, tuples can be dict keys and set members, and they signal fixed structure such as coordinates or database rows.

6. Can you give an example of filter and reduce over an iterable?

from functools import reduce
nums = [3, 8, 12, 5, 20]
evens = list(filter(lambda n: n % 2 == 0, nums))   # [8, 12, 20]
total = reduce(lambda a, b: a + b, evens)          # 40

Strong answer: correct code, plus the note that reduce moved to functools in Python 3 and that a comprehension with sum() is usually clearer.

7. What tools do you use for linting, debugging and profiling?

Strong answer: names real tools and how they used them, for example a linter such as Ruff, Flake8 or Pylint, pdb or an IDE debugger, and cProfile for finding slow functions. Listen for a specific performance problem they found and fixed.

8. How would you reverse a string iteratively and recursively?

def reverse_iter(s):
    out = ""
    for ch in s:
        out = ch + out
    return out
def reverse_rec(s):
    return s if len(s) <= 1 else reverse_rec(s[1:]) + s[0]

Strong answer: both versions, plus the idiomatic slice with a negative step. A score of 4 notes that the recursive version hits the recursion limit on long strings and that repeated string concatenation is quadratic.

9. What are the features of good unit tests and functional tests?

Strong answer: unit tests are fast, isolated, deterministic and test one behavior; functional tests check a feature end to end from the user’s view. Strong candidates use pytest, fixtures and mocks, and explain what they choose not to test.

10. What are the core principles of a REST API, and how does REST differ from RPC?

Strong answer: resources identified by URLs, standard HTTP methods, stateless requests and meaningful status codes. RPC exposes actions (call this function); REST exposes resources (act on this thing). A good candidate can map this to a Django REST Framework or Flask project.

11. How does the Linux whereis command find a command’s binary, source and manual pages?

Strong answer: whereis searches a fixed list of standard system directories for the binary, source and man page files of a command, while which searches the user’s PATH. Treat this as a quick check of comfort on Linux servers rather than a core Python signal.

Practical Python exercises (with what to look for)

Give one or two of these in 30 to 45 minutes. Watch how candidates test their own code.

Exercise 1: Fix the bug

def add_item(item, items=[]):
    items.append(item)
    return items

What to look for: the default list is created once and shared across calls. The fix is items=None, then creating a new list inside the function.

Exercise 2: Remove duplicates and keep order

What to look for: list(dict.fromkeys(values)), or a loop with a seen set. Using set() alone loses order, and a strong candidate says so.

Exercise 3: Count the top words in a text file

What to look for: collections.Counter and most_common(), reading line by line, and handling case and punctuation.

Exercise 4: Process a file too large for memory

What to look for: a generator that yields records one at a time, so memory use stays flat whatever the file size.

Exercise 5: Build a small API endpoint

What to look for: a Flask or Django view with input validation, correct status codes and at least one test.

Glider’s live coding interviews let an interviewer and candidate work through exercises like these in a shared editor.

Python interview questions for experienced developers

  • What is the global interpreter lock, and how does it affect threading? Look for: threads help I/O bound work, multiprocessing or native extensions help CPU bound work, and awareness of the free threaded build introduced experimentally in Python 3.13.
  • When would you use asyncio? Look for: many concurrent I/O operations, and the cost of mixing blocking calls into async code.
  • How do you use type hints in a large codebase? Look for: gradual typing, a type checker such as mypy, and dataclasses or Pydantic models at boundaries.
  • How do you manage dependencies and environments? Look for: virtual environments, pinned versions and a reproducible build.

Behavioral questions

  • Tell me about a slow Python service you made faster. How did you find the bottleneck?
  • Describe code you wrote that you’d write differently today.
  • How do you review a teammate’s pull request?

Score these on the same 1 to 4 scale, looking for evidence and ownership.

Sample Python interview scorecard

AreaWeightScore (1 to 4)
Core Python25%
Practical exercise30%
Frameworks and APIs15%
Testing and debugging15%
Communication and ownership15%

Agree on the weights with the hiring manager before interviews start.

Run Python interviews at scale

For high volume Python hiring, the same questions can run through AI interviews with fixed questions evaluated against a rubric, and a recruiter reviews every result before anyone advances. Hiring for Java too? See the Java developer interview questions guide, or browse the full interview questions library.

Frequently asked questions

What questions should I ask a Python developer?

Ask about argument passing, first class functions, closures, comprehensions, mutable versus immutable types and testing, then give one practical exercise and two behavioral questions.

How do I evaluate a Python developer’s answers?

Score each answer from 1 to 4: recall, explains, applies, judges tradeoffs. Compare scores across interviewers before discussing the candidate.

What are good Python coding interview questions?

Fixing the mutable default argument bug, removing duplicates while keeping order, counting words with Counter, processing a large file with a generator and building a small API endpoint.

What should I ask an experienced Python developer?

The global interpreter lock, asyncio, type hints at scale, profiling a slow service and dependency management.

How long should a Python developer interview take?

Plan 45 to 60 minutes for the technical interview plus 30 to 45 minutes for a practical exercise, after a skills screen.

Should I test Python skills before the interview?

Yes. A proctored technical skill test or a coding simulation confirms fundamentals first, so the interview can go deeper.

Architect Interview Questions: What to Ask Before You Hire

A strong architect portfolio tells you what got built. It rarely tells you what the candidate personally decided, what they gave up when the budget moved, or how they handled a contractor who said the detail couldn’t be built. Those are the things that decide whether a hire works out, and they only come out […]

Benefits Specialist Interview Questions: What to Ask and What Good Answers Sound Like

The best benefits specialist interview questions test four areas: compliance knowledge (COBRA, ERISA, ACA, HIPAA), program administration (open enrollment, vendors, HRIS), employee communication and judgment in sensitive situations. Ask for specific examples, then confirm the skills with a short job based skill test before the final round. A benefits specialist is the person employees call […]

Underwriter Interview Questions: What to Ask and What to Expect

Underwriters review applications, whether for insurance policies or loans, and decide how much risk a company should take on. Get a clear snapshot of how to screen the ideal candidate for your organization with this set of underwriter interview questions. The job of an underwriter is to review insurance or loan applications and carry out […]

chevron-down