1What built-in data types does Python have, and which are mutable?
Python has scalar types such as NoneType, bool, int, float and complex; text and binary types such as str, bytes and bytearray; sequence types such as list, tuple and range; and collection types such as dict, set and frozenset. The important interview distinction is mutability: list, dict, set and bytearray can change in place, while numbers, bool, str, bytes, tuple, range, frozenset and None are immutable. A useful nuance is that a tuple is immutable as a container, but it can still contain references to mutable objects.
2How do list, tuple, set and dict differ in real code?
A list is an ordered mutable sequence, so it is good for queues of work, collected results and ordered data that changes. A tuple is ordered but immutable, so it is useful for fixed records, function returns and values that should not be reassigned. A set stores unique hashable objects and is ideal for membership checks or deduplication. A dict maps hashable keys to values and is the normal structure for indexes, lookups and JSON-like data. In modern Python, dict preserves insertion order, but its main purpose is still key-based access.
3What is the difference between is and ==?
== asks whether two objects are equal by value, usually through __eq__. is asks whether two references point to the exact same object in memory. In production code, is should usually be reserved for singleton checks such as value is None, value is True only when identity really matters, or sentinel objects. Do not rely on implementation details such as small integer caching or string interning; those can make is appear to work in examples while being the wrong semantic choice.
4What is a hashable object and why does it matter?
A hashable object has a hash value that remains stable during its lifetime and equality behavior consistent with that hash. Hashability matters because dict keys and set elements depend on it. Most immutable built-ins are hashable, but not all objects inside an immutable container automatically become hashable: a tuple containing a list is not hashable. In interviews, connect this to design: if an object is used as a key, its identity-defining fields should not change after insertion.
5How does slicing work, including negative indexes and steps?
A slice sequence[start:stop:step] includes start, excludes stop and moves by step. Missing boundaries are inferred from the direction of the step. Negative indexes count from the end, so s[-1] is the last item. A negative step walks from right to left; s[::-1] creates a reversed sequence for many sequence types. The trade-off is that slicing often creates a new object, so it is expressive but not always free for large data.