Top 10 Python Interview Questions
1. What are Python's key features?
- Interpreted, dynamically typed
- High-level language
- Object-oriented
- Extensive standard library
- Supports multiple paradigms (OOP, functional, procedural)
2. What are Python's data types?
- Numeric: int, float, complex
- Sequence: list, tuple, range
- Text: str
- Set: set, frozenset
- Mapping: dict
- Boolean: bool
3. What is the difference between list and tuple?
- List: Mutable, defined using []
- Tuple: Immutable, defined using ()
4. What are *args and **kwargs?
- *args: Variable-length positional arguments
- **kwargs: Variable-length keyword arguments
5. Explain Python's memory management.
- Automatic memory management via reference counting and garbage collection
6. What is a lambda function?
- Anonymous function defined with `lambda` keyword. Example: lambda x: x * 2
7. Difference between is and == in Python?
- is: checks identity (same object)
- ==: checks equality of value
8. What is a Python module and package?
- Module: a single Python file
- Package: a collection of modules in a directory with __init__.py
9. Explain list comprehension.
- A concise way to create lists: [x for x in range(5) if x%2==0]
10. What is the use of decorators in Python?
- Decorators modify the behavior of a function without changing its source code