Python Interview Questions

The data model, closures and decorators, generators, the GIL and when to reach for threads, processes or asyncio, plus the pitfalls that bite in production — mutable defaults, late binding, and blocking the event loop.

Data ModelDecoratorsGeneratorsGIL & asyncioTestingAria-powered explanations
0 / 100 answered
0%
17 Easy57 Medium26 Hard

Showing 120 of 100

#1What does it mean that everything in Python is an object?

Medium
Fundamentals

#2What is the difference between mutable and immutable types, and why does it matter?

Easy
Fundamentals

#3Why is a mutable default argument dangerous?

Easy
Fundamentals

#4What is the difference between is and ==?

Easy
Fundamentals

#5How does Python scoping work — what is LEGB?

Medium
Fundamentals

#6What is the difference between a shallow and a deep copy?

Medium
Fundamentals

#7What are dunder methods and which ones matter most?

Medium
Fundamentals

#8What is the difference between __new__ and __init__?

Hard
Fundamentals

#9What are Python's truthiness rules?

Easy
Fundamentals

#10How does Python manage memory?

Hard
Fundamentals

#11What is duck typing and how does it interact with type hints?

Hard
Fundamentals

#12What does the walrus operator do and when should you use it?

Medium
Fundamentals

#13What is the difference between args and kwargs, and positional-only parameters?

Medium
Fundamentals

#14How do Python imports actually work?

Medium
Fundamentals

#15How is a Python list implemented and what are its complexities?

Medium
Data Structures

#16How does a Python dict work and what guarantees does it give?

Medium
Data Structures

#17When would you use a tuple instead of a list?

Easy
Data Structures

#18What is collections.defaultdict and when is it better than dict?

Easy
Data Structures

#19What is a deque and when do you need one?

Medium
Data Structures

#20What is the difference between a set and a frozenset?

Easy
Data Structures

Showing 120 of 100

Ask Aria about Python

Sign in to chat with Aria

All 100 Python questions at a glance
  1. What does it mean that everything in Python is an object?(Medium)
  2. What is the difference between mutable and immutable types, and why does it matter?(Easy)
  3. Why is a mutable default argument dangerous?(Easy)
  4. What is the difference between is and ==?(Easy)
  5. How does Python scoping work — what is LEGB?(Medium)
  6. What is the difference between a shallow and a deep copy?(Medium)
  7. What are dunder methods and which ones matter most?(Medium)
  8. What is the difference between __new__ and __init__?(Hard)
  9. What are Python's truthiness rules?(Easy)
  10. How does Python manage memory?(Hard)
  11. What is duck typing and how does it interact with type hints?(Hard)
  12. What does the walrus operator do and when should you use it?(Medium)
  13. What is the difference between args and kwargs, and positional-only parameters?(Medium)
  14. How do Python imports actually work?(Medium)
  15. How is a Python list implemented and what are its complexities?(Medium)
  16. How does a Python dict work and what guarantees does it give?(Medium)
  17. When would you use a tuple instead of a list?(Easy)
  18. What is collections.defaultdict and when is it better than dict?(Easy)
  19. What is a deque and when do you need one?(Medium)
  20. What is the difference between a set and a frozenset?(Easy)
  21. What are dataclasses and when would you use one over a NamedTuple or a plain class?(Medium)
  22. How do you sort with a custom key efficiently?(Medium)
  23. What is the difference between a list comprehension and a generator expression?(Medium)
  24. How do you merge dictionaries and what are the options?(Easy)
  25. What is collections.Counter useful for?(Easy)
  26. When would you use heapq or bisect?(Hard)
  27. What is a closure and what is the late binding gotcha?(Hard)
  28. How does a decorator work?(Medium)
  29. What does functools.lru_cache do and when is it unsafe?(Medium)
  30. What is the difference between a function and a method, and what do staticmethod and classmethod do?(Medium)
  31. How would you write a retry decorator?(Medium)
  32. What is a context manager and how do you write one?(Medium)
  33. What are first-class functions and how do partial and higher-order functions help?(Medium)
  34. When should you use a lambda and when should you not?(Easy)
  35. How do you write a decorator that works on both functions and methods?(Hard)
  36. What is functools.singledispatch?(Hard)
  37. What are type hints good for if Python ignores them at runtime?(Medium)
  38. How do you handle exceptions well in Python?(Medium)
  39. How does multiple inheritance and the MRO work?(Hard)
  40. What are properties and when should you use one?(Medium)
  41. What is the descriptor protocol?(Hard)
  42. What are __slots__ and when do they help?(Hard)
  43. What is a metaclass and when would you actually need one?(Hard)
  44. What is an abstract base class and how does it differ from a Protocol?(Hard)
  45. What does the underscore convention mean in Python?(Easy)
  46. How do you implement equality and hashing correctly?(Medium)
  47. What is the difference between composition and inheritance in Python specifically?(Medium)
  48. What does super() actually do?(Hard)
  49. How do you make a class iterable, and what is the difference between iterable and iterator?(Medium)
  50. What is the point of __repr__ and how should you write one?(Easy)
  51. What is a generator and how does yield work?(Medium)
  52. What does yield from do?(Hard)
  53. How do you process a large file without loading it into memory?(Medium)
  54. What is itertools and which functions are worth knowing?(Medium)
  55. What is the difference between an iterator and a generator?(Medium)
  56. What is generator send() used for?(Hard)
  57. How do comprehensions compare to map and filter?(Easy)
  58. What happens if you modify a collection while iterating it?(Medium)
  59. How do you implement pagination or chunking over an iterable?(Medium)
  60. What are the memory implications of generators versus lists in a pipeline?(Medium)
  61. What is the GIL and what does it actually prevent?(Medium)
  62. When do you use threading, multiprocessing, and asyncio?(Medium)
  63. How does asyncio actually work?(Hard)
  64. What is the difference between awaiting sequentially and using gather?(Medium)
  65. What happens if you call a blocking function inside async code?(Hard)
  66. What is the difference between a coroutine, a task, and a future?(Hard)
  67. How do you limit concurrency in asyncio?(Hard)
  68. What is multiprocessing and what are its costs?(Medium)
  69. What is concurrent.futures and when is it the right abstraction?(Medium)
  70. How do you share state safely between threads in Python?(Hard)
  71. What is asyncio.Queue used for?(Medium)
  72. How do you handle timeouts and cancellation in asyncio?(Hard)
  73. What is the difference between asyncio and threading for a web server?(Hard)
  74. What are common asyncio mistakes?(Hard)
  75. How would you speed up a CPU-bound Python workload?(Medium)
  76. What changes with the free-threaded build in Python 3.13?(Hard)
  77. What standard library modules should every backend Python developer know?(Easy)
  78. How should you handle dates and times correctly?(Medium)
  79. How should logging be configured in an application?(Medium)
  80. What is the difference between pathlib and os.path?(Easy)
  81. How do you manage configuration and secrets in a Python application?(Medium)
  82. What is the difference between random and secrets?(Medium)
  83. How do you run a subprocess safely?(Medium)
  84. What is the difference between pip, venv, poetry and uv?(Medium)
  85. What is the walrus of string formatting — which method should you use?(Easy)
  86. What is the difference between JSON serialisation options in Python?(Medium)
  87. Why do most Python projects use pytest rather than unittest?(Easy)
  88. What are pytest fixtures and what do the scopes mean?(Medium)
  89. How does mocking work in Python and what should you mock?(Medium)
  90. How do you test code that depends on the current time?(Medium)
  91. What is parametrised testing and why is it valuable?(Medium)
  92. How do you test async code?(Hard)
  93. What makes a Python test suite slow, and how do you fix it?(Medium)
  94. What is a flaky test and how do you deal with one?(Medium)
  95. How do you profile a Python application?(Medium)
  96. What are the most common accidental performance problems in Python?(Medium)
  97. How do you find and fix a memory leak in Python?(Hard)
  98. When should you reach for NumPy instead of built-in types?(Medium)
  99. What Python-specific things would you check in a code review?(Medium)
  100. What distinguishes idiomatic Python from code that works?(Medium)