Huru
Technical Interviews

Python Interview Questions for Junior Developers (With Answers and Code, 2026)

Python interview questions for junior developers and freshers with short answers and code: data types, mutability, lists vs tuples, dictionaries, the mutable default argument trap, comprehensions, functions, classes, exceptions, generators, common coding exercises, and how to prepare.

By Amine Boukioud Updated 4 min read
The Huru mascot typing happily on a laptop next to a plush blue and yellow snake, with a code panel and a green check mark floating nearby

The short answer: junior Python interviews check that you understand the core language (data types, mutability, lists, dictionaries, functions, classes, exceptions), can write clean code for small problems (string and list manipulation, counting, searching), and can explain your thinking. Expect a few concept questions, one or two live coding exercises, and questions about a project you built. Below are the most common questions with short answers and code, typical coding exercises, and how to prepare.

Data types and mutability

“What’s the difference between mutable and immutable types?”

Mutable objects can be changed in place (lists, dictionaries, sets); immutable ones can’t (integers, floats, strings, tuples, frozensets). Changing a string creates a new string.

“What’s the difference between a list and a tuple?”

Lists are mutable and usually hold items you’ll add to or change; tuples are immutable, slightly lighter, and can be used as dictionary keys if their contents are hashable.

“What’s the difference between == and is?”

== compares values; is checks whether two names refer to the same object. Use is for None: if x is None.

“How do dictionaries work, and what can be a key?”

They map keys to values using hashing, so lookups are fast on average. Keys must be hashable (immutable types such as strings, numbers or tuples of immutables).

The mutable default argument trap

A classic question. The Python tutorial warns: “The default value is evaluated only once.” So a mutable default is shared between calls:

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

add_item(1)  # [1]
add_item(2)  # [1, 2]  -- surprise!

The fix, as the tutorial shows:

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

Functions and comprehensions

“What are *args and **kwargs?”

*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dictionary.

“What is a list comprehension?”

A concise way to build a list:

squares = [n * n for n in range(10) if n % 2 == 0]

There are also dictionary and set comprehensions, and generator expressions with parentheses.

“What’s a lambda?”

A small anonymous function, often used as a key: sorted(people, key=lambda p: p["age"]).

Classes

“What’s the difference between a class and an instance?”

A class is the blueprint; an instance is an object created from it. __init__ sets up each instance’s attributes.

“What is self?”

The instance the method is called on, passed automatically as the first argument.

“What is inheritance?”

A class can reuse and extend another class’s behavior. Know how to call the parent’s method with super().

Errors and files

“How do you handle exceptions?”

try:
    value = int(text)
except ValueError:
    value = 0
finally:
    print("done")

Catch specific exceptions, not a bare except:.

“Why use with when opening files?”

It closes the file automatically, even if an error occurs: with open("data.txt") as f:.

Iterators and generators

“What is a generator?”

A function that uses yield to produce values one at a time, so it doesn’t build the whole sequence in memory. Useful for large files or streams.

Common coding exercises

Practice these until you can write them cleanly and explain them:

  • Reverse a string, and check if a string is a palindrome.
  • Count how often each word appears in a sentence (with a dictionary or collections.Counter).
  • Find duplicates in a list.
  • FizzBuzz.
  • Find the two numbers in a list that add up to a target.
  • Merge two sorted lists.
  • Remove duplicates from a list while keeping the order.
from collections import Counter

def top_words(text, n=3):
    words = text.lower().split()
    return Counter(words).most_common(n)

Talk through your approach first, write a simple correct solution, test it with a couple of examples including edge cases (empty input), and then mention how you could make it faster.

Questions about your projects

Juniors are often asked to walk through a project: what it does, why you built it, the hardest bug, what you’d do differently. Prepare one project you can explain in detail. See tell me about a time you solved a complex problem and describe your most challenging project.

How to prepare

  1. Review the Python tutorial sections on data structures, functions, classes and errors.
  2. Solve 20 to 30 easy problems out loud, explaining as you go.
  3. Write a small project you can talk about, with a README.
  4. Practice the behavioral questions too: “Tell me about yourself,” “Why this company?” See our common interview questions.

For live coding platforms, see our guides to HackerRank tests and CoderPad interviews.

Frequently asked questions

What Python questions are asked in a junior developer interview?
Questions on data types and mutability, lists vs tuples, dictionaries, == vs is, the mutable default argument trap, *args and **kwargs, comprehensions, classes and self, exceptions, the with statement and generators, plus a couple of simple coding exercises.
What is the mutable default argument problem in Python?
Default values are evaluated only once, when the function is defined, so a mutable default such as a list is shared across calls. Use None as the default and create a new list inside the function.
What's the difference between a list and a tuple in Python?
Lists are mutable and can be changed in place; tuples are immutable and can be used as dictionary keys if their contents are hashable.
What coding exercises do junior Python developers get?
Common ones include reversing a string, checking palindromes, counting words, finding duplicates, FizzBuzz, two-sum, merging sorted lists and removing duplicates while keeping order.
How do I prepare for a junior Python interview?
Review the core language from the Python tutorial, solve 20 to 30 easy problems out loud, build a small project you can explain, and practice behavioral questions such as Tell me about yourself.

Sources

Practice this with Huru AI

Turn what you just read into a rehearsal. Unlimited AI mock interviews with instant, specific feedback.

Amine Boukioud

Amine Boukioud is Head of Growth at Huru and writes Huru’s company interview guides. Each one starts from the company’s own careers pages and what candidates report, and follows Huru’s editorial policy.

Published · Updated

How this article was made: researched and drafted with AI assistance, then written, fact-checked and signed by Amine Boukioud on October 1, 2026. Sources are linked where they are used. How we work: editorial policy.