gitGood.dev

Python Interview Questions

Practice Python questions covering data structures, decorators, generators, comprehensions, and Pythonic programming patterns.

36
Total Questions
15
Easy
18
Medium
3
Hard
Showing 1-20 of 36 questionsPage 1 of 2
Sign up to start practicing these questionsSign up free →
Dynamic Typing
QuizEasy
Mutable vs Immutable Types
QuizEasy
is vs ==
QuizEasy
Pass by Object Reference
QuizMedium
Global Interpreter Lock
QuizMedium
Memory Management
QuizMedium
List vs Tuple
QuizEasy
Dictionary Implementation
QuizMedium
List Comprehensions
QuizEasy
Generators
QuizMedium
Iterator Protocol
QuizMedium
__init__ vs __new__
QuizMedium
Method Resolution Order
QuizHard
@property Decorator
QuizEasy
__slots__
QuizMedium
Dunder Methods
QuizEasy
Abstract Base Classes
QuizMedium
*args and **kwargs
QuizEasy
Closures and Scope
QuizMedium
Decorators
QuizMedium

Frequently Asked Questions

What Python topics are commonly tested in interviews?

Built-in data structures (lists, dicts, sets, tuples), list comprehensions, generators, decorators, context managers, OOP in Python, exception handling, and the standard library (collections, itertools). For data roles, also know NumPy, Pandas, and basic ML concepts.

Is Python a good language choice for coding interviews?

Python is excellent for interviews. Its concise syntax lets you write solutions quickly, and its rich standard library (collections.Counter, heapq, defaultdict) simplifies many problems. Most FAANG companies accept Python, and it's the most popular choice among candidates.

What are Python decorators and how do they work?

Decorators are functions that modify other functions. They use the @decorator syntax and wrap a function to add behavior before/after it runs. Common uses include logging, timing, authentication, and caching. Understanding closures is key to understanding decorators.

What is the difference between a list and a tuple?

Lists are mutable (can be modified after creation) while tuples are immutable. Tuples are slightly faster and can be used as dictionary keys. Use tuples for fixed data like coordinates or database rows, and lists when you need to add, remove, or modify elements.

How do generators work in Python?

Generators are functions that use yield instead of return, producing values one at a time lazily. They save memory by not storing the entire sequence. Generator expressions (x for x in range(n)) are the expression form. They are ideal for processing large datasets or infinite sequences.

What is the GIL and how does it affect Python?

The Global Interpreter Lock (GIL) in CPython prevents true parallel execution of Python bytecode across threads. CPU-bound tasks should use multiprocessing instead of threading. I/O-bound tasks (network, file) still benefit from threading because the GIL is released during I/O operations.

Explore Other Categories