Python Concepts for Interviews (Basic
to Advanced)
1. Python Basics
• Python is a high-level, interpreted, object-oriented programming language.
• Data Types: int, float, complex, str, bool, list, tuple, set, dict.
• Lists: mutable & ordered, Tuples: immutable & ordered, Sets: unordered & unique, Dicts:
key-value pairs.
• Operators: Arithmetic (+, -, *, /, %), Comparison (==, !=, >, <), Logical (and, or, not).
• Conditional statements: if-elif-else.
• Loops: for, while, with break, continue, pass.
2. Intermediate Python
• Functions: Defined using def. Supports default args, *args, **kwargs.
• Modules: single .py file, Packages: collection of modules.
• Exception handling: try-except-finally-else.
• File handling: with open('file.txt', 'r') as f.
• OOP concepts: class, object, inheritance, encapsulation, polymorphism.
3. Advanced Python
• Decorators: Functions that modify behavior of other functions (@decorator).
• Generators: Functions with yield, return values lazily.
• Iterators: Objects implementing __iter__() and __next__().
• Context Managers: Manage resources using with keyword.
• Multithreading vs Multiprocessing: Threads good for I/O, Processes for CPU.
• Python Memory Management: Reference counting + garbage collection.
• Virtual Environments: python -m venv env, isolates dependencies.
• Built-in functions: map(), filter(), reduce(), zip(), enumerate(), sorted().
• Dunder Methods: __init__, __str__, __len__, __getitem__.
• Libraries: NumPy, Pandas, Matplotlib, Django, Flask, TensorFlow, PyTorch.
4. Interview-Focused Python Q&A
• Mutable vs Immutable: Mutable (list, dict, set), Immutable (tuple, string, int).
• Shallow vs Deep copy: Shallow shares nested references, Deep fully copies.
• Pass by value or reference: Python is pass by object reference.
• is vs ==: is checks identity, == checks value equality.
• GIL: Global Interpreter Lock allows only one thread at a time.