Skip to content
C

Interview Questions

Python Interview Questions

Python interview questions and answers, organized by topic, with examples and key points for quick revision.

Python Basics

Python as a language -- what makes it high-level and dynamically typed, and how CPython actually runs a program.

Open 5 questions

Data Types & Variables

Variables, built-in data types, dynamic vs strong typing, and Python's core equality and mutability rules.

Open 10 questions

Lists, Tuples, Sets & Dictionaries

Lists, tuples, sets, dictionaries, comprehensions, slicing, unpacking, and the built-in methods that manipulate them.

Open 15 questions

Functions

Function definitions, argument passing, *args/**kwargs, lambdas, decorators, recursion, and variable scope.

Open 15 questions

Strings

Python's immutable string type -- formatting, splitting, joining, and Unicode handling.

Open 8 questions

Exception Handling

try/except/else/finally, raising and chaining exceptions, and custom exception design.

Open 8 questions

OOP

Classes, objects, constructors, inheritance, MRO, polymorphism, encapsulation, abstraction, and property-based APIs.

Open 14 questions

File Handling

Opening files, file modes, and why context managers are the safe way to work with them.

Open 3 questions

Modules & Packages

Modules, packages, the import system, pip, and the script-vs-import execution guard.

Open 9 questions

Iterators, Generators & Functional Tools

Iterables, iterators, generators, and the built-in functional tools -- enumerate, zip, map, filter, reduce.

Open 14 questions

Multithreading & Concurrency

Threading, the GIL, multiprocessing, concurrent.futures, asyncio, and safe coordination of concurrent work.

Open 9 questions

Memory Management

Reference counting, garbage collection, shallow vs deep copy, object identity, weak references, and context managers.

Open 14 questions

Advanced Python

Type hints, duck typing, EAFP/LBYL, monkey patching, introspection, __slots__, hashability, closures, and descriptors.

Open 15 questions

Special Methods & Operator Overloading

Dunder methods for equality, representation, construction, and operator overloading, plus common OOP design patterns.

Open 10 questions

Testing & Tooling

Logging, unit testing, pytest, calling REST APIs safely, and preventing SQL injection.

Open 6 questions

Serialization & Data Interchange

Converting Python objects to and from JSON and pickle, and the safety trade-offs between them.

Open 4 questions

Python Runtime Internals

The Python virtual machine, bytecode, and the __pycache__ bytecode cache.

Open 3 questions

Environment, CLI & Packaging

Virtual environments, dependency management, pyproject.toml/wheels, and Python's environment/CLI/filesystem standard library.

Open 17 questions

Algorithms & Data Structures

Time/space complexity, common data-structure patterns (Counter, deque, stack, queue, heap), sorting, and caching.

Open 29 questions

Typing & Modern Python Syntax

namedtuple, Protocol, Optional/Union, match-case, the walrus operator, and positional-/keyword-only parameters.

Open 12 questions

Builtins, Control Flow & Scope

any()/all(), loop control flow, scope, closures, and Python's namespace model.

Open 14 questions

Type Checking & Abstract Classes

isinstance/issubclass, ABC virtual subclasses, namespace packages, and dynamic/lazy imports.

Open 6 questions