/Python Interview Questions: Core, OOP & Data
Programming 10 min read

Python Interview Questions: Core, OOP & Data

Core Python, data structures, OOP, decorators, and common pitfalls — with crisp answers.

Introduction

This guide is for Python developers across data, backend, and automation roles. Python interviews test language fluency and idiomatic usage more than raw algorithmic difficulty.

Read this if you want a focused refresher on the concepts interviewers probe most.

Overview

  • Core: mutable vs immutable, scoping, iterators, generators.
  • OOP: dunder methods, inheritance, MRO, dataclasses.
  • Idioms: comprehensions, decorators, context managers.
  • Ecosystem: NumPy/Pandas for data, Django/Flask for web, pytest for testing.

Preparation Tips

  • Understand 'is' vs '==' and the integer caching gotcha.
  • Know how list vs tuple mutability affects hashing and use as dict keys.
  • Be ready to explain decorators (functions returning functions) and @property.
  • For data roles, revise Pandas vectorization and groupby semantics.
  • Practice writing clean, Pythonic one-liners vs readable loops.

Top Interview Questions

1. What's the difference between list and tuple?

Lists are mutable, tuples immutable. Tuples can be dict keys; lists can't. Tuples have lower overhead.

2. Explain decorators in Python.

A decorator is a function taking a function and returning a new one, using @syntax. Used for logging, caching, auth — closures capture the original.

3. What are *args and **kwargs?

*args collects positional args as a tuple; **kwargs collects keyword args as a dict. Enables flexible function signatures.

4. How does a generator differ from a list?

Generators yield values lazily, saving memory. Use for large streams; iterate once unless re-created.

5. What is the GIL?

The Global Interpreter Lock serializes CPython bytecode execution per process, limiting true CPU parallelism in threads — use multiprocessing for CPU-bound work.

Common Mistakes

  • Using mutable default arguments (def f(x=[])).
  • Confusing 'is' with '==' for value comparison.
  • Iterating and modifying a list simultaneously.
  • Ignoring the GIL for CPU-bound threading.

Expert Tips

  • Mention memory efficiency when explaining generators.
  • For data roles, show you understand vectorization over row loops.
  • Use context managers (with) when discussing resource cleanup.
  • Write Pythonic code in interviews; readability is graded.

Frequently Asked Questions

Is Python good for backend interviews?

Yes — clean syntax makes DSA easier to express; many companies accept Python for coding rounds.

How important is the GIL?

Important for concurrency questions; know when to use threads vs multiprocessing.

Should I learn type hints?

Increasingly expected in production code; mention them to show seniority.

Do Python interviews ask DSA?

Often, but lighter than Java/C++ rounds; idioms and correctness matter more.

Related Articles

Ready to test yourself?

Practice Python questions with an AI interviewer and get instant feedback on clarity.

Start a Mock Interview

Practice this with AI feedback

PrepyX listens to your answers and gives you instant, detailed feedback — structure, clarity, confidence, and more.

Try PrepyX Free