INTERVIEW QUESTIONS

Python Interview Questions

Practice Python prompts by theme and build clearer interview answers.

Practice by topicRole and skill lensesClear answer prompts

Showing 52 practice prompts

✦

PYTHON

What is Python and what makes it dynamically typed?

Python is an interpreted, high-level, dynamically typed language. In Python, variables do not have fixed types; type binding occurs at runtime when a value is assigned. The interpreter infers the data type dynamically based on the object bound to the identifier, meaning a variable name can point to an integer, then later to a string or list.
◦ fundamentals
✦

PYTHON

What is the difference between mutable and immutable data types in Python?

Immutable types cannot have their in-place value modified after creation; any modification creates a new object in memory (e.g., `int`, `float`, `str`, `tuple`, `frozenset`, `bool`). Mutable types can be modified in-place without changing their memory address/identity (e.g., `list`, `dict`, `set`, bytearray).
◦ fundamentals
✦

PYTHON

What is the difference between a List and a Tuple?

Lists are mutable sequences defined with square brackets `[]` where elements can be appended, removed, or replaced in-place. Tuples are immutable sequences defined with parentheses `()` whose structure cannot change after creation. Tuples are faster, consume less memory, and can be used as dictionary keys (if all elements are hashable).
◦ fundamentals
✦

PYTHON

What are List Comprehensions and what are their benefits?

List comprehensions provide a concise syntax to create new lists from existing iterables: `[expr for item in iterable if condition]`. They are generally faster than traditional `for` loops with `append()` because the iteration and appending bytecode operations are executed in optimized C-level loops within the CPython interpreter.
◦ fundamentals
✦

PYTHON

Explain Python's LEGB rule for variable scope.

The LEGB rule determines the order in which Python resolves variable names: 1) Local (inside current function), 2) Enclosing (in enclosing/nested functions), 3) Global (at module level), and 4) Built-in (predefined names like `len`, `range`, `print`). The `global` and `nonlocal` keywords allow explicit assignment to outer scopes.
◦ fundamentals
…

Your next interview is closer than you think.

Practice smarter and land better opportunities.

✓ Start with the free plan✓ No credit card✓ Cancel anytime
Start preparing free