Hiring guide

Python Developer Interview Questions

March 31, 2026
34 min read

These Python Developer interview questions will guide your interview process to help you find trusted candidates with the right skills you are looking for.

120 Python Developer Interview Questions

  1. What is Python, and what are its key features?

  2. What is the __init__() method in Python?

  3. What is the difference between lists and tuples in Python?

  4. What is the difference between mutable and immutable data types?

  5. What is slicing in Python?

  6. What is the difference between global and local scope in Python?

  7. What is PEP 8 and why is it important?

  8. What is an interpreted language?

  9. What is a dynamically typed language?

  10. What is indentation in Python and why is it important?

  11. What is the difference between Python arrays and lists?

  12. Explain list, dictionary, and tuple comprehension with examples

  13. What are Dict and List comprehensions?

  14. What are negative indexes and why are they used?

  15. How do you copy a list in Python?

  16. What is the difference between shallow copy and deep copy?

  17. Which collection does not allow duplicate members?

  18. What is a KeyError in Python and how can you handle it?

  19. How can you use Python's collections module to simplify common tasks?

  20. What are Python namespaces and why are they used?

  21. What are lambda functions in Python?

  22. What does *args and **kwargs mean?

  23. What are decorators in Python?

  24. Explain the split() and join() functions

  25. What is the purpose of the pass statement?

  26. What is the use of self in Python?

  27. How would you use ternary operators in Python?

  28. What are generators in Python?

  29. What are context managers in Python and how are they implemented?

  30. What is the Python "with" statement designed for?

  31. What is a class in Python and how do you create one?

  32. How does inheritance work in Python?

  33. How do you access parent class members in a child class?

  34. How do you check if a class is a child of another class?

  35. What are global, protected, and private attributes in Python?

  36. What is monkey patching in Python?

  37. What are metaclasses in Python?

  38. Can you create an empty class in Python?

  39. What is polymorphism in Python?

  40. What is encapsulation in Python?

  41. What is the difference between modules and packages in Python?

  42. How do you import modules in Python?

  43. What is the __init__.py file used for?

  44. What is the purpose of the __name__ == "__main__" statement?

  45. How do you manage dependencies in Python projects?

  46. What is pip and how is it used?

  47. What are Python wheels?

  48. How do you create your own Python package?

  49. What is the sys module used for?

  50. What is the os module and what are its common uses?

  51. What is the difference between syntax errors and exceptions?

  52. How do you handle exceptions in Python?

  53. What is the purpose of the finally block?

  54. How do you create custom exceptions in Python?

  55. What is the difference between raise and assert?

  56. What are common built-in exceptions in Python?

  57. How do you chain exceptions in Python?

  58. What is the difference between except Exception and bare except?

  59. How do you log exceptions in Python?

  60. What is exception hierarchy in Python?

  61. How do you read and write files in Python?

  62. What is the difference between read(), readline(), and readlines()?

  63. How do you handle CSV files in Python?

  64. How do you work with JSON files in Python?

  65. What is the difference between binary and text file modes?

  66. How do you check if a file exists in Python?

  67. How do you delete files and directories in Python?

  68. What is file serialization and how is it done in Python?

  69. How do you work with file paths across different operating systems?

  70. What is the difference between tell() and seek() methods?

  71. What is the Global Interpreter Lock (GIL)?

  72. What is the difference between multithreading and multiprocessing?

  73. What are iterators and iterables in Python?

  74. What is the difference between @staticmethod and @classmethod?

  75. What are property decorators and how do they work?

  76. What is memory management in Python?

  77. What is garbage collection in Python?

  78. What are closures in Python?

  79. What is the difference between __str__ and __repr__?

  80. What are magic methods (dunder methods) in Python?

  81. How do you write unit tests in Python?

  82. What is pytest and how does it differ from unittest?

  83. What are fixtures in pytest?

  84. How do you mock objects in Python tests?

  85. What is test-driven development (TDD)?

  86. How do you debug Python code?

  87. What is code coverage and how do you measure it?

  88. What is the difference between integration and unit tests?

  89. How do you profile Python code for performance?

  90. What are parametrized tests?

  91. What are the popular Python web frameworks?

  92. What is Django and what are its key features?

  93. What is Flask and when would you use it?

  94. What is REST API and how do you build one in Python?

  95. What is FastAPI and what makes it different?

  96. How do you handle database operations in Django?

  97. What is SQLAlchemy and how is it used?

  98. How do you handle authentication in web applications?

  99. What is WSGI and ASGI?

  100. How do you deploy Python web applications?

  101. What is NumPy and what are its key features?

  102. What is Pandas and how is it used for data manipulation?

  103. What is the difference between Series and DataFrame in Pandas?

  104. How do you handle missing data in Pandas?

  105. What is Matplotlib and how do you create visualizations?

  106. What is scikit-learn and what can it be used for?

  107. What is the difference between supervised and unsupervised learning?

  108. How do you handle large datasets that don't fit in memory?

  109. What is Jupyter Notebook and why is it useful?

  110. What are some popular Python libraries for deep learning?

  111. What are Python coding best practices?

  112. How do you optimize Python code for performance?

  113. What is thedifference between is and == in Python?

  114. What are Python's anti-patterns you should avoid?

  115. How do you write Pythonic code?

  116. What is the difference between deepcopy and copy?

  117. How do you handle configuration in Python applications?

  118. What is the purpose of virtual environments?

  119. How do you implement logging in Python applications?

  120. What security considerations should you keep in mind when writing Python code?

Download Free Python Developer Interview Questions

Get expert-crafted questions designed specifically for python developer roles. Our comprehensive PDF includes technical, behavioral, and ethics questions to help you identify top talent.

Fundamental Python Concepts

What is Python, and what are its key features?

What to Listen For:

  • Clear explanation of Python as a high-level, interpreted language with emphasis on readability and simplicity
  • Mention of key features like dynamic typing, extensive standard library, cross-platform compatibility, and support for multiple programming paradigms
  • Understanding of Python's advantages such as rapid development, strong community support, and versatility across domains like web development, data science, and automation

What is the __init__() method in Python?

What to Listen For:

  • Recognition that __init__() is a constructor method automatically called when creating new class instances
  • Understanding of its purpose in initializing object attributes and setting up initial state
  • Ability to explain the role of the 'self' parameter and how it references the instance being created

What is the difference between lists and tuples in Python?

What to Listen For:

  • Clear distinction that lists are mutable (can be modified) while tuples are immutable (cannot be changed after creation)
  • Understanding of performance implications - tuples are faster and use less memory than lists
  • Recognition of appropriate use cases: lists for collections requiring modification, tuples for fixed data or dictionary keys

What is the difference between mutable and immutable data types?

What to Listen For:

  • Correct identification of mutable types (list, dict, set) and immutable types (int, float, string, tuple)
  • Understanding that mutable objects can be changed in-place while immutable objects create new objects when modified
  • Awareness of memory and performance implications, particularly with large data structures

What is slicing in Python?

What to Listen For:

  • Understanding of slice syntax [start:stop:step] and how it extracts portions of sequences
  • Knowledge of default values (start=0, stop=length, step=1) and negative indexing capabilities
  • Practical examples demonstrating slicing on strings, lists, or tuples with correct syntax

What is the difference between global and local scope in Python?

What to Listen For:

  • Clear explanation that local variables exist only within functions while global variables are accessible throughout the program
  • Understanding of the 'global' keyword and when it's necessary to modify global variables from within functions
  • Awareness of scope resolution order and best practices for avoiding naming conflicts

What is PEP 8 and why is it important?

What to Listen For:

  • Recognition that PEP 8 is Python's official style guide for writing clean, readable code
  • Mention of key guidelines like indentation, naming conventions, line length, and import organization
  • Understanding of its importance for code consistency, maintainability, and collaboration in team environments

What is an interpreted language?

What to Listen For:

  • Explanation that interpreted languages execute code line-by-line without prior compilation to machine code
  • Understanding of advantages like easier debugging, platform independence, and dynamic execution
  • Awareness that Python actually compiles to bytecode (.pyc files) before interpretation by the Python Virtual Machine

What is a dynamically typed language?

What to Listen For:

  • Understanding that dynamic typing means type checking occurs at runtime rather than compile-time
  • Recognition that variables don't require explicit type declarations and can change types during execution
  • Awareness of the flexibility benefits and potential runtime error risks associated with dynamic typing

What is indentation in Python and why is it important?

What to Listen For:

  • Recognition that indentation defines code blocks in Python, not just for readability but as syntactical requirement
  • Understanding that inconsistent indentation causes IndentationError and prevents code execution
  • Awareness of standard practice (4 spaces per indentation level) and importance for code structure
Data Structures & Collections

What is the difference between Python arrays and lists?

What to Listen For:

  • Understanding that arrays require homogeneous data types while lists can contain heterogeneous elements
  • Recognition that arrays are more memory-efficient and faster for numerical operations
  • Knowledge that arrays require importing the array module while lists are built-in data structures

Explain list, dictionary, and tuple comprehension with examples

What to Listen For:

  • Demonstration of comprehension syntax for creating lists and dictionaries in single lines of code
  • Understanding that tuple comprehensions actually create generator expressions requiring tuple() conversion
  • Ability to show conditional logic and nested iterations within comprehensions

What are Dict and List comprehensions?

What to Listen For:

  • Recognition that comprehensions provide concise syntax for creating collections from iterables
  • Practical examples showing filtering, transformation, or mathematical operations using comprehensions
  • Understanding of performance benefits and readability advantages over traditional for-loops

What are negative indexes and why are they used?

What to Listen For:

  • Understanding that negative indexes count from the end of sequences (-1 being the last element)
  • Recognition of their utility for accessing elements from the end without knowing sequence length
  • Practical examples demonstrating negative indexing with lists, strings, or tuples

How do you copy a list in Python?

What to Listen For:

  • Understanding that simple assignment (list2 = list1) creates a reference, not a copy
  • Knowledge of shallow copy methods: copy() method, list() constructor, or slice notation [:]
  • Awareness of deep copy using copy.deepcopy() for nested structures requiring independent copies

What is the difference between shallow copy and deep copy?

What to Listen For:

  • Clear explanation that shallow copies duplicate the outer object but reference inner nested objects
  • Understanding that deep copies recursively duplicate all nested objects, creating completely independent structures
  • Recognition of when to use each method based on data structure complexity and modification requirements

Which collection does not allow duplicate members?

What to Listen For:

  • Immediate identification that sets and frozensets do not allow duplicate elements
  • Understanding that duplicates are automatically removed when added to sets
  • Awareness of use cases where uniqueness is required, such as removing duplicates from lists

What is a KeyError in Python and how can you handle it?

What to Listen For:

  • Recognition that KeyError occurs when accessing non-existent dictionary keys
  • Knowledge of handling methods: .get() with default values, try-except blocks, or 'in' operator checks
  • Understanding of defaultdict from collections module as an alternative approach

How can you use Python's collections module to simplify common tasks?

What to Listen For:

  • Familiarity with specialized data structures like Counter, defaultdict, deque, and OrderedDict
  • Practical examples showing Counter for element counting or defaultdict for avoiding KeyError
  • Understanding of performance benefits and appropriate use cases for each collection type

What are Python namespaces and why are they used?

What to Listen For:

  • Understanding that namespaces are mappings of names to objects, implemented as dictionaries
  • Knowledge of different namespace types: local, global, built-in, and their scope hierarchy
  • Recognition that namespaces prevent naming conflicts and organize code logically
Functions & Methods

What are lambda functions in Python?

What to Listen For:

  • Recognition that lambda functions are anonymous, single-expression functions defined inline
  • Understanding of appropriate use cases with map(), filter(), sorted(), or as short-lived callbacks
  • Awareness of limitations: single expression only, less readable for complex operations

What does *args and **kwargs mean?

What to Listen For:

  • Understanding that *args allows functions to accept variable numbers of positional arguments as a tuple
  • Recognition that **kwargs accepts variable keyword arguments as a dictionary
  • Practical examples showing how to unpack and use these arguments within functions

What are decorators in Python?

What to Listen For:

  • Clear explanation that decorators are functions that modify or extend the behavior of other functions
  • Understanding of the @ syntax and how decorators wrap existing functions
  • Practical examples such as logging, timing, authentication, or caching use cases

Explain the split() and join() functions

What to Listen For:

  • Understanding that split() divides strings into lists based on delimiters
  • Recognition that join() concatenates list elements into a single string with specified separators
  • Practical examples demonstrating text parsing, data formatting, or string manipulation

What is the purpose of the pass statement?

What to Listen For:

  • Understanding that pass is a null operation placeholder that does nothing when executed
  • Recognition of use cases: empty function/class bodies during development, maintaining code structure
  • Awareness that it prevents syntax errors where Python expects an indented block

What is the use of self in Python?

What to Listen For:

  • Clear explanation that 'self' represents the instance of the class and allows access to attributes and methods
  • Understanding that it must be the first parameter in instance methods but isn't a keyword (convention only)
  • Recognition of its role in distinguishing instance variables from local variables within methods

How would you use ternary operators in Python?

What to Listen For:

  • Understanding of the syntax: value_if_true if condition else value_if_false
  • Practical examples showing concise conditional assignments in single lines
  • Awareness of readability considerations and when traditional if-else statements are more appropriate

What are generators in Python?

What to Listen For:

  • Understanding that generators are functions that yield values one at a time using the yield keyword
  • Recognition of memory efficiency benefits for large datasets by generating values on-demand
  • Practical examples showing lazy evaluation and iteration without storing entire sequences in memory

What are context managers in Python and how are they implemented?

What to Listen For:

  • Understanding that context managers manage resources using __enter__ and __exit__ methods
  • Recognition of the 'with' statement for automatic resource cleanup and exception handling
  • Practical examples with file handling, database connections, or custom context managers

What is the Python "with" statement designed for?

What to Listen For:

  • Recognition that 'with' statements ensure proper resource management and cleanup
  • Understanding of automatic exception handling and guaranteed cleanup even when errors occur
  • Common use cases: file operations, database connections, locks, and network connections
Object-Oriented Programming

What is a class in Python and how do you create one?

What to Listen For:

  • Understanding that classes are blueprints for creating objects with defined attributes and methods
  • Demonstration of class creation using the 'class' keyword and instantiation of objects
  • Knowledge of __init__ method for initialization and self parameter for instance reference

How does inheritance work in Python?

What to Listen For:

  • Clear explanation of inheritance allowing child classes to derive attributes and methods from parent classes
  • Understanding of different inheritance types: single, multiple, multilevel, and hierarchical
  • Knowledge of super() function for accessing parent class methods and proper initialization

How do you access parent class members in a child class?

What to Listen For:

  • Knowledge of using super() to call parent class methods and access attributes
  • Alternative approach of directly using parent class name to access members
  • Understanding of method resolution order (MRO) in multiple inheritance scenarios

How do you check if a class is a child of another class?

What to Listen For:

  • Knowledge of issubclass() function to check class inheritance relationships
  • Understanding of isinstance() to verify if an object is an instance of a specific class
  • Practical examples demonstrating correct usage and return values for both methods

What are global, protected, and private attributes in Python?

What to Listen For:

  • Understanding that Python uses naming conventions rather than enforced access modifiers
  • Recognition of single underscore (_var) for protected members and double underscore (__var) for private members
  • Awareness that these are conventions indicating intended usage, not absolute restrictions

What is monkey patching in Python?

What to Listen For:

  • Understanding that monkey patching modifies classes or modules at runtime by changing their attributes or methods
  • Recognition of use cases in testing, debugging, or extending third-party libraries
  • Awareness of potential risks: reduced code readability, maintenance challenges, and unexpected behavior

What are metaclasses in Python?

What to Listen For:

  • Understanding that metaclasses are classes of classes that define how classes behave
  • Recognition that while regular classes create objects, metaclasses create classes
  • Awareness of advanced use cases like enforcing coding standards, automatic method generation, or ORM implementations

Can you create an empty class in Python?

What to Listen For:

  • Knowledge that empty classes are created using the 'pass' statement as a placeholder
  • Understanding that attributes and methods can be added toinstances dynamically after instantiation
  • Recognition of use cases like data containers, placeholders during development, or namespace objects

What is polymorphism in Python?

What to Listen For:

  • Understanding that polymorphism allows objects of different classes to be treated through the same interface
  • Recognition of method overriding and duck typing as Python's approach to polymorphism
  • Practical examples showing how different objects can respond to the same method call in class-specific ways

What is encapsulation in Python?

What to Listen For:

  • Understanding that encapsulation bundles data and methods within a class while restricting direct access
  • Knowledge of using naming conventions (single/double underscores) to indicate access levels
  • Recognition of benefits: data hiding, reduced complexity, increased security, and improved maintainability
Modules & Packages

What is the difference between modules and packages in Python?

What to Listen For:

  • Clear distinction that modules are single Python files (.py) containing code, while packages are directories containing multiple modules
  • Understanding that packages require an __init__.py file (though optional in Python 3.3+) to be recognized as packages
  • Recognition of how packages organize related modules into hierarchical namespace structures

How do you import modules in Python?

What to Listen For:

  • Knowledge of various import statements: import module, from module import function, import module as alias
  • Understanding of best practices regarding import organization and avoiding wildcard imports (from module import *)
  • Awareness of relative vs absolute imports in package structures

What is the __init__.py file used for?

What to Listen For:

  • Understanding that __init__.py marks directories as Python packages and executes when the package is imported
  • Recognition of its uses: package initialization code, defining __all__ for import control, and exposing package-level APIs
  • Awareness that it's optional in Python 3.3+ but still recommended for explicit package definition

What is the purpose of the __name__ == "__main__" statement?

What to Listen For:

  • Understanding that this idiom allows code to run only when the script is executed directly, not when imported
  • Recognition that __name__ is set to "__main__" for the main program and to the module name when imported
  • Practical examples showing how to write reusable modules with test/demo code that only runs when executed directly

How do you manage dependencies in Python projects?

What to Listen For:

  • Knowledge of requirements.txt files for listing project dependencies with pip freeze command
  • Understanding of virtual environments (venv, virtualenv) for isolating project dependencies
  • Awareness of modern tools like pipenv, poetry, or conda for advanced dependency management

What is pip and how is it used?

What to Listen For:

  • Recognition that pip is Python's package installer for downloading and managing packages from PyPI
  • Knowledge of common commands: install, uninstall, freeze, list, and show
  • Understanding of version specification and installing from requirements.txt files

What are Python wheels?

What to Listen For:

  • Understanding that wheels (.whl) are built package distributions that install faster than source distributions
  • Recognition that wheels contain pre-compiled code, eliminating build steps during installation
  • Awareness of wheel benefits: faster installation, consistent builds, and reduced installation errors

How do you create your own Python package?

What to Listen For:

  • Knowledge of creating directory structure with __init__.py, setup.py, and README files
  • Understanding of setup.py for defining package metadata, dependencies, and distribution settings
  • Awareness of building and distributing packages to PyPI using setuptools and twine

What is the sys module used for?

What to Listen For:

  • Understanding that sys provides access to system-specific parameters and functions
  • Knowledge of common uses: command-line arguments (sys.argv), exit program (sys.exit()), path manipulation (sys.path)
  • Practical examples demonstrating version checking, standard input/output redirection, or interpreter information

What is the os module and what are its common uses?

What to Listen For:

  • Recognition that os module provides operating system-dependent functionality
  • Knowledge of common operations: file/directory manipulation, environment variables, path operations, process management
  • Practical examples showing os.path, os.listdir(), os.environ, or os.system() usage
Error Handling & Exceptions

What is the difference between syntax errors and exceptions?

What to Listen For:

  • Understanding that syntax errors occur during parsing and prevent code execution, while exceptions occur during runtime
  • Recognition that syntax errors must be fixed before the program runs, but exceptions can be caught and handled
  • Examples demonstrating each type: missing colons/parentheses for syntax errors, division by zero for exceptions

How do you handle exceptions in Python?

What to Listen For:

  • Knowledge of try-except blocks for catching and handling exceptions gracefully
  • Understanding of else clause (executes if no exception) and finally clause (always executes for cleanup)
  • Awareness of catching specific exceptions vs generic Exception class and best practices

What is the purpose of the finally block?

What to Listen For:

  • Understanding that finally blocks execute regardless of whether exceptions occurred or were caught
  • Recognition of its use for cleanup operations: closing files, releasing resources, disconnecting from databases
  • Practical examples showing guaranteed execution even with return statements or unhandled exceptions

How do you create custom exceptions in Python?

What to Listen For:

  • Knowledge of creating custom exception classes by inheriting from Exception or specific exception types
  • Understanding of when custom exceptions improve code clarity and error handling specificity
  • Practical examples showing custom exception definitions with optional __init__ and __str__ methods

What is the difference between raise and assert?

What to Listen For:

  • Understanding that raise explicitly throws exceptions, while assert tests conditions and raises AssertionError if false
  • Recognition that assertions are for debugging and can be disabled with optimization flags (-O)
  • Awareness that raise is for error handling in production, while assert is for development-time sanity checks

What are common built-in exceptions in Python?

What to Listen For:

  • Familiarity with frequently encountered exceptions: ValueError, TypeError, KeyError, IndexError, AttributeError
  • Understanding of file-related exceptions: FileNotFoundError, IOError, PermissionError
  • Recognition of when each exception type typically occurs and how to handle them appropriately

How do you chain exceptions in Python?

What to Listen For:

  • Knowledge of using "raise ... from ..." syntax to explicitly chain exceptions
  • Understanding that exception chaining preserves the original exception context while raising a new one
  • Recognition of __cause__ and __context__ attributes for accessing exception chain information

What is the difference between except Exception and bare except?

What to Listen For:

  • Understanding that bare except catches all exceptions including system-exiting ones like KeyboardInterrupt
  • Recognition that except Exception catches most exceptions but allows system exits and other BaseException subclasses
  • Awareness that bare except is generally discouraged as it can hide serious problems and make debugging difficult

How do you log exceptions in Python?

What to Listen For:

  • Knowledge of the logging module for structured exception logging with different severity levels
  • Understanding of logging.exception() method that automatically includes traceback information
  • Practical examples showing proper exception logging within except blocks for debugging and monitoring

What is exception hierarchy in Python?

What to Listen For:

  • Understanding that all exceptions inherit from BaseException, with most inheriting from Exception
  • Recognition of the hierarchy structure: BaseException ? Exception ? specific exception types
  • Awareness that catching parent exceptions also catches all child exceptions in the hierarchy
File Handling & I/O

How do you read and write files in Python?

What to Listen For:

  • Knowledge of open() function with different modes: 'r' (read), 'w' (write), 'a' (append), 'r+' (read/write)
  • Understanding of read methods: read(), readline(), readlines() and write methods: write(), writelines()
  • Best practice of using 'with' statements for automatic file closing and resource management

What is the difference between read(), readline(), and readlines()?

What to Listen For:

  • Understanding that read() returns entire file content as a single string
  • Recognition that readline() reads one line at a time, returning a string
  • Knowledge that readlines() returns a list containing all lines as separate string elements

How do you handle CSV files in Python?

What to Listen For:

  • Knowledge of the csv module with csv.reader() and csv.writer() for basic operations
  • Understanding of DictReader and DictWriter for working with CSV files as dictionaries
  • Awareness of pandas library as a more powerful alternative for complex CSV operations

How do you work with JSON files in Python?

What to Listen For:

  • Knowledge of json module with json.load() for reading and json.dump() for writing to files
  • Understanding of json.loads() and json.dumps() for converting between JSON strings and Python objects
  • Awareness of serialization options like indent, sort_keys, and handling custom objects

What is the difference between binary and text file modes?

What to Listen For:

  • Understanding that text mode ('r', 'w') handles string data with encoding/decoding, while binary mode ('rb', 'wb') handles raw bytes
  • Recognition that binary mode is necessary for non-text files like images, executables, or serialized data
  • Awareness of encoding considerations (UTF-8, ASCII) when working with text files

How do you check if a file exists in Python?

What to Listen For:

  • Knowledge of os.path.exists() for checking file or directory existence
  • Understanding of os.path.isfile() and os.path.isdir() for specific type checking
  • Awareness of pathlib.Path.exists() as a modern, object-oriented alternative

How do you delete files and directories in Python?

What to Listen For:

  • Knowledge of os.remove() for deleting files and os.rmdir() for empty directories
  • Understanding of shutil.rmtree() for removing directories with contents
  • Awareness of error handling when files don't exist or permissions are insufficient

What is file serialization and how is it done in Python?

What to Listen For:

  • Understanding that serialization converts Python objects into byte streams for storage or transmission
  • Knowledge of pickle module for Python-specific serialization and deserialization
  • Awareness of alternatives like JSON for language-independent serialization or protocol buffers for efficiency

How do you work with file paths across different operating systems?

What to Listen For:

  • Knowledge of os.path.join() for creating OS-independent file paths
  • Understanding of pathlib.Path for modern, object-oriented path manipulation
  • Awareness of path separator differences (forward slash vs backslash) and how Python handles them

What is the difference between tell() and seek() methods?

What to Listen For:

  • Understanding that tell() returns the current position in the file as a byte offset
  • Recognition that seek() moves the file pointer to a specified position
  • Practical examples showing how to navigate within files for random access operations
Advanced Python Concepts

What is the Global Interpreter Lock (GIL)?

What to Listen For:

  • Understanding that GIL is a mutex preventing multiple threads from executing Python bytecode simultaneously
  • Recognition of its impact on CPU-bound multi-threaded programs and why they don't achieve true parallelism
  • Awareness of workarounds: multiprocessing for CPU-bound tasks, or using I/O-bound operations where GIL releases

What is the difference between multithreading and multiprocessing?

What to Listen For:

  • Understanding that multithreading shares memory space while multiprocessing uses separate memory spaces
  • Recognition that multithreading is better for I/O-bound tasks, multiprocessing for CPU-bound tasks
  • Knowledge of Python's threading and multiprocessing modules and their appropriate use cases

What are iterators and iterables in Python?

What to Listen For:

  • Understanding that iterables are objects that can return an iterator (implement __iter__)
  • Recognition that iterators maintain state and return values one at a time (implement __next__)
  • Practical examples showing how to create custom iterators or use iter() and next() functions

What is the difference between @staticmethod and @classmethod?

What to Listen For:

  • Understanding that @staticmethod doesn't receive any implicit first argument, while @classmethod receives the class as first argument (cls)
  • Recognition that @classmethod can access/modify class state and create alternative constructors
  • Practical examples showing appropriate use cases for each decorator type

What are property decorators and how do they work?

What to Listen For:

  • Understanding that @property allows method calls to appear as attribute access
  • Knowledge of @property.setter and @property.deleter for defining getter, setter, and deleter methods
  • Practical examples demonstrating encapsulation, validation, or computed attributes using properties

What is memory management in Python?

What to Listen For:

  • Understanding that Python uses automatic memory management with a private heap space
  • Knowledge of garbage collection using reference counting and cyclic garbage collector
  • Awareness of memory optimization techniques and when to use gc module for manual control

What is garbage collection in Python?

What to Listen For:

  • Understanding that garbage collection automatically reclaims memory from objects no longer in use
  • Recognition of reference counting as primary mechanism and generational garbage collection for cycles
  • Knowledge of gc module for tuning collection behavior or manually triggering collection

What are closures in Python?

What to Listen For:

  • Understanding that closures are functions that remember values from their enclosing scope
  • Recognition that closures allow data hiding and can be used to create function factories
  • Practical examples showing nested functions accessing outer function variables after outer function returns

What is the difference between __str__ and __repr__?

What to Listen For:

  • Understanding that __str__ is for readable end-user output, while __repr__ is for unambiguous developer representation
  • Recognition that __repr__ should ideally return code that recreates the object
  • Knowledge that print() uses __str__, while interactive console uses __repr__

What are magic methods (dunder methods) in Python?

What to Listen For:

  • Understanding that magic methods have double underscores and define behavior for built-in operations
  • Knowledge of common magic methods: __init__, __str__, __len__, __add__, __eq__, __getitem__
  • Practical examples showing operator overloading or customizing object behavior
Testing & Debugging

How do you write unit tests in Python?

What to Listen For:

  • Knowledge of unittest module as Python's built-in testing framework
  • Understanding of test class structure inheriting from unittest.TestCase with test methods prefixed with 'test_'
  • Familiarity with assertion methods: assertEqual, assertTrue, assertRaises, and setUp/tearDown methods

What is pytest and how does it differ from unittest?

What to Listen For:

  • Recognition that pytest is a third-party framework with simpler syntax and more features than unittest
  • Understanding of pytest advantages: plain assert statements, fixtures, parametrization, better output
  • Knowledge of pytest features like test discovery, markers, plugins, and fixture scope management

What are fixtures in pytest?

What to Listen For:

  • Understanding that fixtures are reusable setup code for tests, defined with @pytest.fixture decorator
  • Knowledge of fixture scopes: function, class, module, session for controlling when fixtures execute
  • Practical examples showing dependency injection and teardown logic using yield statements

How do you mock objects in Python tests?

What to Listen For:

  • Knowledge of unittest.mock module with Mock and MagicMock classes for creating test doubles
  • Understanding of patching with @patch decorator or patch context manager to replace dependencies
  • Practical examples showing return_value, side_effect, and assertion methods like assert_called_with

What is test-driven development (TDD)?

What to Listen For:

  • Understanding that TDD involves writing tests before implementation following red-green-refactor cycle
  • Recognition of benefits: better design, fewer bugs, documentation through tests, confidence in refactoring
  • Awareness of when TDD is appropriate and potential challenges in adoption

How do you debug Python code?

What to Listen For:

  • Knowledge of pdb (Python debugger) for interactive debugging with breakpoints and stepping
  • Understanding of print debugging, logging, and IDE debugging tools
  • Familiarity with debugging commands: break, continue, step, next, list, print variables

What is code coverage and how do you measure it?

What to Listen For:

  • Understanding that code coverage measures percentage of code executed by tests
  • Knowledge of coverage.py tool for measuring and reporting code coverage
  • Awareness that high coverage doesn't guarantee quality but helps identify untested code paths

What is the difference between integration and unit tests?

What to Listen For:

  • Understanding that unit tests verify individual components in isolation with mocked dependencies
  • Recognition that integration tests verify interactions between multiple components or systems
  • Knowledge of test pyramid: many unit tests, fewer integration tests, even fewer end-to-end tests

How do you profile Python code for performance?

What to Listen For:

  • Knowledge of cProfile module for deterministic profiling of Python programs
  • Understanding of timeit module for measuring execution time of small code snippets
  • Familiarity with memory profiling tools like memory_profiler or line_profiler for detailed analysis

What are parametrized tests?

What to Listen For:

  • Understanding that parametrized tests run the same test logic with different input values
  • Knowledge of pytest's @pytest.mark.parametrize decorator for defining test parameters
  • Recognition of benefits: reduced code duplication, comprehensive testing, clear test cases
Web Development with Python

What are the popular Python web frameworks?

What to Listen For:

  • Familiarity with Django as a full-featured "batteries included" framework
  • Knowledge of Flask as a lightweight, flexible micro-framework
  • Awareness of FastAPI for building modern APIs with automatic documentation and async support

What is Django and what are its key features?

What to Listen For:

  • Understanding of Django's MVT (Model-View-Template) architecture
  • Knowledge of built-in features: ORM, admin interface, authentication, forms, templating
  • Recognition of Django's philosophy: "don't repeat yourself" and convention over configuration

What is Flask and when would you use it?

What to Listen For:

  • Understanding that Flask is a minimalist framework providing routing, templating, and request handling
  • Recognition of use cases: small to medium projects, APIs, microservices, or when you need flexibility
  • Knowledge of Flask extensions for adding functionality like database integration, authentication, or API support

What is REST API and how do you build one in Python?

What to Listen For:

  • Understanding of REST principles: stateless, resource-based, HTTP methods, status codes
  • Knowledge of building APIs with Flask-RESTful, Django REST Framework, or FastAPI
  • Practical examples showing endpoint creation, request handling, serialization, and authentication

What is FastAPI and what makes it different?

What to Listen For:

  • Understanding that FastAPI is built on Starlette and Pydantic with automatic API documentation
  • Recognition of key features: async/await support, type hints for validation, high performance
  • Knowledge of automatic OpenAPI and JSON Schema generation from type annotations

How do you handle database operations in Django?

What to Listen For:

  • Knowledge of Django ORM for database operations without writing SQL
  • Understanding of models, migrations, querysets, and CRUD operations
  • Practical examples showing model definitions, relationships, and query optimization techniques

What is SQLAlchemy and how is it used?

What to Listen For:

  • Understanding that SQLAlchemy is a powerful ORM and database toolkit for Python
  • Knowledge of Core (SQL expression language) and ORM layers
  • Practical examples showing model definitions, sessions, queries, and relationship configurations

How do you handle authentication in web applications?

What to Listen For:

  • Knowledge of session-based authentication, token-based (JWT), and OAuth implementations
  • Understanding of Django's authentication system or Flask-Login for session management
  • Awareness of security considerations: password hashing, HTTPS, CSRF protection, secure session storage

What is WSGI and ASGI?

What to Listen For:

  • Understanding that WSGI (Web Server Gateway Interface) is a specification for synchronous Python web applications
  • Recognition that ASGI (Asynchronous Server Gateway Interface) extends WSGI to support async applications
  • Knowledge of servers: Gunicorn/uWSGI for WSGI, Uvicorn/Daphne for ASGI

How do you deploy Python web applications?

What to Listen For:

  • Knowledge of deployment platforms: Heroku, AWS, Google Cloud, DigitalOcean, or containerization with Docker
  • Understanding of production setup: WSGI/ASGI servers, reverse proxies (Nginx), static file serving
  • Awareness of considerations: environment variables, database migrations, logging, monitoring, and scaling
Data Science & Machine Learning

What is NumPy and what are its key features?

What to Listen For:

  • Understanding that NumPy provides efficient multi-dimensional array operations and mathematical functions
  • Knowledge of ndarray as the core data structure with vectorized operations
  • Practical examples showing array creation, indexing, slicing, broadcasting, and linear algebra operations

What is Pandas and how is it used for data manipulation?

What to Listen For:

  • Understanding that Pandas provides DataFrame and Series structures for data analysis
  • Knowledge of common operations: filtering, grouping, merging, pivoting, handling missing data
  • Practical examples showing data loading, cleaning, transformation, and analysis workflows

What is the difference between Series and DataFrame in Pandas?

What to Listen For:

  • Understanding that Series is a one-dimensional labeled array, while DataFrame is two-dimensional (rows and columns)
  • Recognition that DataFrame is essentially a collection of Series sharing the same index
  • Knowledge of when to use each: Series for single column operations, DataFrame for tabular data

How do you handle missing data in Pandas?

What to Listen For:

  • Knowledge of methods: dropna() for removal, fillna() for imputation, interpolate() for estimating values
  • Understanding of isnull() and notnull() for identifying missing values
  • Awareness of strategies: forward fill, backward fill, mean/median imputation, or domain-specific approaches

What is Matplotlib and how do you create visualizations?

What to Listen For:

  • Understanding that Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations
  • Knowledge of pyplot interface for quick plotting and object-oriented approach for customization
  • Practical examples showing line plots, bar charts, histograms, scatter plots with customization options

What is scikit-learn and what can it be used for?

What to Listen For:

  • Understanding that scikit-learn provides machine learning algorithms for classification, regression, clustering
  • Knowledge of preprocessing, model selection, evaluation metrics, and pipelines
  • Practical examples showing train-test split, model fitting, prediction, and cross-validation

What is the difference between supervised and unsupervised learning?

What to Listen For:

  • Understanding that supervised learning uses labeled data to train models for prediction
  • Recognition that unsupervised learning finds patterns in unlabeled data
  • Examples of each: classification/regression for supervised, clustering/dimensionality reduction for unsupervised

How do you handle large datasets that don't fit in memory?

What to Listen For:

  • Knowledge of chunking with Pandas read_csv(chunksize) or iterating through data in batches
  • Understanding of Dask for parallel computing on larger-than-memory datasets
  • Awareness of database queries, data sampling, or cloud-based solutions for massive datasets

What is Jupyter Notebook and why is it useful?

What to Listen For:

  • Understanding that Jupyter provides interactive coding environment with executable cells
  • Recognition of benefits: exploratory analysis, documentation with markdown, visualization inline, reproducibility
  • Awareness of use cases in data science, education, and collaborative research

What are some popular Python libraries for deep learning?

What to Listen For:

  • Familiarity with TensorFlow and Keras for building neural networks
  • Knowledge of PyTorch as a flexible, research-focused deep learning framework
  • Awareness of specialized libraries: Hugging Face Transformers, FastAI, or JAX
Best Practices & Performance

What are Python coding best practices?

What to Listen For:

  • Knowledge of PEP 8 style guide, meaningful naming conventions, and proper documentation
  • Understanding of DRY (Don't Repeat Yourself), KISS (Keep It Simple), and SOLID principles
  • Awareness of code organization, error handling, testing, and version control practices

How do you optimize Python code for performance?

What to Listen For:

  • Knowledge of profiling to identify bottlenecks before optimization
  • Understanding of techniques: list comprehensions, generators, built-in functions, caching, vectorization
  • Awareness of when to use NumPy, Cython, or PyPy for performance-critical code

What is thedifference between is and == in Python?

What to Listen For:

  • Understanding that 'is' checks identity (same object in memory) while '==' checks value equality
  • Recognition that 'is' compares memory addresses using id() function
  • Practical examples showing when to use each: 'is' for None/True/False, '==' for value comparisons

What are Python's anti-patterns you should avoid?

What to Listen For:

  • Awareness of common mistakes: mutable default arguments, bare except clauses, using 'is' for value comparison
  • Recognition of poor practices: wildcard imports, global variables abuse, not using context managers
  • Understanding of code smells: deep nesting, long functions, tight coupling, lack of documentation

How do you write Pythonic code?

What to Listen For:

  • Understanding of Python idioms: list comprehensions, context managers, unpacking, enumerate, zip
  • Knowledge of "The Zen of Python" principles: explicit is better than implicit, simple is better than complex
  • Practical examples showing preference for built-in functions and standard library over custom implementations

What is the difference between deepcopy and copy?

What to Listen For:

  • Understanding that copy creates a shallow copy (new outer object, references to inner objects)
  • Recognition that deepcopy recursively copies all nested objects creating completely independent structures
  • Practical examples showing when modifications to copied objects affect or don't affect the original

How do you handle configuration in Python applications?

What to Listen For:

  • Knowledge of environment variables, configuration files (JSON, YAML, INI), or Python modules
  • Understanding of libraries: configparser, python-decouple, or dynaconf for configuration management
  • Awareness of best practices: separating config from code, different configs for environments, secret management

What is the purpose of virtual environments?

What to Listen For:

  • Understanding that virtual environments isolate project dependencies to avoid conflicts
  • Knowledge of tools: venv (built-in), virtualenv, conda, or pipenv
  • Recognition of benefits: reproducible environments, clean system Python, easier collaboration

How do you implement logging in Python applications?

What to Listen For:

  • Knowledge of logging module with different levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
  • Understanding of handlers, formatters, and configuration for controlling log output
  • Practical examples showing structured logging, log rotation, and best practices for production applications

What security considerations should you keep in mind when writing Python code?

What to Listen For:

  • Awareness of common vulnerabilities: SQL injection, XSS, CSRF, insecure deserialization
  • Understanding of secure practices: input validation, password hashing, using HTTPS, avoiding eval()
  • Knowledge of security libraries: secrets module, cryptography, parameterized queries, security headers
Start Here
Get Python Developer Job Description Template
Create a compelling python developer job posting before you start interviewing

How X0PA AI Helps You Hire Python Developer

Hiring Python Developers shouldn't mean spending weeks screening resumes, conducting endless interviews, and still ending up with someone who leaves in 6 months.

X0PA AI uses predictive analytics across 6 key hiring stages, from job posting to assessment to find candidates who have the skills to succeed and the traits to stay.

Job Description Creation

Multi-Channel Sourcing

AI-Powered Screening

Candidate Assessment

Process Analytics

Agentic AI