PYTHON FUNDAMENTALS Q&A
1. What are Pythons key features?
- Interpreted, Dynamically Typed, High-level, Object-Oriented, Vast Standard Library, Cross-platform.
2. Difference between list and tuple?
- List is mutable, Tuple is immutable.
3. Explain *args and **kwargs.
- *args: Non-keyworded variable length arguments.
- **kwargs: Keyworded variable length arguments.
4. What are Python's data types?
- int, float, complex, bool, str, list, tuple, dict, set, frozenset, NoneType.
5. Difference between is and ==?
- is: identity (memory location); ==: value equality.
...
ADVANCED PYTHON Q&A
1. What is GIL?
- Global Interpreter Lock: Only one thread executes Python bytecode at a time.
2. Use case for threading vs multiprocessing?
- Threading: I/O-bound; Multiprocessing: CPU-bound.
3. What is interning?
- Python reuses small immutable objects (like strings, ints) for memory efficiency.
4. Mutable vs Immutable Types?
- Mutable: list, dict, set; Immutable: int, str, tuple, frozenset.
5. What is @staticmethod vs @classmethod?
- @staticmethod: doesnt receive class or instance.
- @classmethod: receives class as first argument.
6. Use of enumerate, zip, map, filter?
- Useful iterators to work with sequences efficiently.
7. How to debug Python?
- Use pdb.set_trace() or IDE debuggers.
8. What is __init__.py?
- Makes a folder a package.
9. How to type annotate?
- def func(a: int) -> str: ...
10. What is Pythonic code?
- Readable, idiomatic use of Python features.
And many more... covering decorators, generators, exception handling, memory profiling, testing, and best