|
Core Python Concepts
|
|
|
|
Difference between == and is in Python
|
|
|
|
Explain Python’s memory management and garbage collection
|
|
|
|
What is the LEGB rule in Python?
|
|
|
|
Explain the difference between deep copy and shallow copy
|
|
|
|
What are Python’s data model (dunder) methods?
|
|
|
|
What are generators and how do they differ from iterators?
|
|
|
|
What is the Global Interpreter Lock (GIL)?
|
|
|
|
What is the purpose of the __new__() method?
|
|
|
|
Explain Python's with statement
|
|
|
|
What are closures in Python?
|
|
|
Object-Oriented Programming (OOP)
|
|
|
|
What is the difference between a class method and a static method?
|
|
|
|
How is inheritance implemented in Python?
|
|
|
|
How does multiple inheritance work?
|
|
|
|
What is method resolution order (MRO)?
|
|
|
|
What is encapsulation and abstraction?
|
|
|
|
How is polymorphism implemented in Python?
|
|
|
|
What are metaclasses?
|
|
|
|
What are descriptors in Python?
|
|
|
|
What is monkey patching?
|
|
|
|
What is __slots__ and when should it be used?
|
|
|
Functional Programming
|
|
|
|
Explain map(), filter(), and reduce()
|
|
|
|
What are lambda functions and their limitations?
|
|
|
|
What are *args and **kwargs used for?
|
|
|
|
What is functools.lru_cache and where is it used?
|
|
|
|
What is a closure?
|
|
|
|
How do decorators work?
|
|
|
|
What is the difference between a decorator function and a Decorator Pattern?
|
|
|
|
What are first-class and higher-order functions?
|
|
|
Modules, Packaging, and Imports
|
|
|
|
Difference between module and package in Python
|
|
|
|
What is __init__.py used for?
|
|
|
|
What is __main__.py used for?
|
|
|
|
What is the purpose of __all__?
|
|
|
|
How does Python's import mechanism work?
|
|
|
|
How do you structure a large Python project?
|
|
|
|
How do you publish a package to PyPI?
|
|
|
|
What’s the difference between setup.py, pyproject.toml, and requirements.txt?
|
|
|
|
What is tox used for?
|
|
|
File Handling and I/O
|
|
|
|
How do you read a file line-by-line?
|
|
|
|
How do you read/write CSV and JSON files?
|
|
|
|
What’s the difference between binary and text mode?
|
|
|
|
How do you handle large files in Python?
|
|
|
|
What are common file I/O exceptions?
|
|
|
|
What are context managers?
|
|
|
Error Handling
|
|
|
|
How does Python handle exceptions?
|
|
|
|
Difference between raise, try, and assert
|
|
|
|
How do you create custom exceptions?
|
|
|
|
What is the use of finally?
|
|
|
|
What are context managers and how are they implemented?
|
|
|
Data Structures
|
|
|
|
Differences: list vs tuple vs set vs dict
|
|
|
|
How do you implement a stack/queue in Python?
|
|
|
|
What are namedtuples?
|
|
|
|
How do you sort a dictionary by values?
|
|
|
|
What’s in the collections module?
|
|
|
|
When should you use a defaultdict or Counter?
|
|
|
Concurrency and Parallelism
|
|
|
|
Differences: threading, multiprocessing, asyncio
|
|
|
|
How does the GIL affect multithreading?
|
|
|
|
What is an event loop?
|
|
|
|
How do you prevent race conditions?
|
|
|
|
How do asyncio.gather() and asyncio.create_task() differ?
|
|
|
|
Difference between coroutine and generator
|
|
|
|
How do you use concurrent.futures?
|
|
|
Advanced Topics & Internals
|
|
|
|
How does Python compile and run code?
|
|
|
|
What are .pyc files?
|
|
|
|
How do you inspect bytecode in Python?
|
|
|
|
What is the dis module?
|
|
|
|
What are interned strings?
|
|
|
|
What is __dict__ in Python objects?
|
|
|
|
How do you dynamically create a class?
|
|
|
|
What are weak references?
|
|
|
|
How does memory allocation work in Python?
|
|
|
Performance and Optimization
|
|
|
|
How do you identify bottlenecks in code?
|
|
|
|
When should you use NumPy or Cython?
|
|
|
|
What is lazy evaluation?
|
|
|
|
What is timeit and when to use it?
|
|
|
|
How do you reduce memory usage in Python?
|
|
|
|
What are memory profiling tools (tracemalloc, memory_profiler)?
|
|
|
|
How does caching work (lru_cache, custom caching)?
|
|
|
|
How does garbage collection work in Python?
|
|
|
Testing and Debugging
|
|
|
|
What is unit testing?
|
|
|
|
Difference between unittest and pytest
|
|
|
|
How do you mock dependencies?
|
|
|
|
How do you test async functions?
|
|
|
|
How do you do test coverage analysis?
|
|
|
|
What are assertions in testing?
|
|
|
|
How do you use pdb for debugging?
|
|
|
Static Typing and Linting
|
|
|
|
What is type hinting in Python?
|
|
|
|
What are Protocols (PEP 544)?
|
|
|
|
How do you use mypy?
|
|
|
|
What is the difference between flake8, black, pylint, and isort?
|
|
|
|
How do linters and formatters differ?
|
|
|
|
How do you type hint a dictionary with fixed structure?
|
|
|
Design Patterns in Python
|
|
|
|
Implement Singleton pattern
|
|
|
|
What is the Factory pattern?
|
|
|
|
Strategy pattern using functions
|
|
|
|
Observer pattern implementation
|
|
|
|
What are common Pythonic patterns?
|
|
|
Web and APIs
|
|
|
|
How do you make HTTP requests?
|
|
|
|
Difference between requests, httpx, and urllib
|
|
|
|
How to handle retries and timeouts?
|
|
|
|
How do you build an API with Flask or FastAPI?
|
|
|
|
How do you parse JSON and XML in Python?
|
|
|
Databases and ORMs
|
|
|
|
How do you connect to a SQL database?
|
|
|
|
What is an ORM? Use SQLAlchemy/Django ORM
|
|
|
|
How do you avoid SQL injection?
|
|
|
|
How do you bulk insert millions of records?
|
|
|
|
How to handle transactions in Python?
|
|
|
Security in Python
|
|
|
|
How do you store passwords securely?
|
|
|
|
Common web security issues in Python apps
|
|
|
|
How do you use hashlib or bcrypt?
|
|
|
|
How do you encrypt/decrypt data in Python?
|
|
|
|
How do you manage secrets in production apps?
|
|
|
Deployment and Production
|
|
|
|
How do you use Docker with Python?
|
|
|
|
How do you monitor a Python application in production?
|
|
|
|
What are common logging practices?
|
|
|
|
How do you configure a production-ready FastAPI app?
|
|
|
|
What are the benefits of using gunicorn or uvicorn?
|
|
|
Metaprogramming and Reflection
|
|
|
|
What is metaprogramming?
|
|
|
|
Use of getattr, setattr, hasattr
|
|
|
|
What is the inspect module used for?
|
|
|
|
How do you modify a class at runtime?
|
|
|
|
Use of reflection and introspection
|
|
|
|
When to use metaclasses?
|
|
|
Interfacing with Other Languages
|
|
|
|
How to use ctypes or cffi for C/C++?
|
|
|
|
What is Cython?
|
|
|
|
How to embed Python in another application?
|
|
|
|
How do you run shell commands in Python?
|
|
|
|
Difference between os.system, subprocess.run, and shlex?
|
|
|
Architecture and Large-Scale Systems
|
|
|
|
How to design a background task queue?
|
|
|
|
Tools for handling high-throughput APIs in Python
|
|
|
|
How do you implement caching (Redis/Memcached)?
|
|
|
|
How to scale Python microservices?
|
|
|
|
How do you handle configuration across environments?
|
|
|
Data Engineering and ML Integration
|
|
|
|
How do you preprocess large datasets in Pandas?
|
|
|
|
How do you handle missing data efficiently?
|
|
|
|
Use of joblib in ML pipelines
|
|
|
|
Difference between NumPy and Pandas memory models
|
|
|
|
How to deploy ML models with FastAPI?
|
|
|
Miscellaneous and Tricky Questions
|
|
|
|
What happens if you use a mutable default argument in a function?
|
|
|
|
Explain __eq__() and when to override it
|
|
|
|
What is duck typing?
|
|
|
|
What are Python anti-patterns to avoid?
|
|
|
|
How do you dynamically import a module or function?
|
|
|
|
How do you handle circular imports?
|
|
|
|
How do you create plugin-based systems in Python?
|
|
|
|
What is the role of the signal module?
|
|
|
|
How do contextvars differ from thread-locals?
|
|
|
|
What are abstract base classes?
|
|
|
Real-World System Design with Python
|
|
|
|
How would you build a distributed task queue in Python?
|
|
|
|
What Python libraries are suitable for pub/sub systems?
|
|
|
|
How would you design a real-time chat application in Python?
|
|
|
|
How would you integrate a message broker (RabbitMQ/Kafka) in Python?
|
|
|
|
What’s your approach to scaling Python services horizontally?
|
|
|
Python in the Cloud and DevOps
|
|
|
|
How do you write Python code for AWS Lambda?
|
|
|
|
What are cold starts in serverless Python functions?
|
|
|
|
How do you manage secrets in AWS/GCP with Python?
|
|
|
|
How do you deploy a FastAPI app with Docker + ECS or Kubernetes?
|
|
|
|
How do you schedule and monitor Python cron jobs in production?
|
|
|
|
What’s the best way to log from Python apps running in containers?
|
|
|
|
How can Python be used for infrastructure-as-code (e.g. Pulumi)?
|
|
|
|
How do you monitor memory/cpu/network of a Python app in the cloud?
|
|
|
Data Pipelines and Streaming in Python
|
|
|
|
How do you handle backpressure in data pipelines with Python?
|
|
|
|
What are some libraries for stream processing in Python?
|
|
|
|
How do you process real-time logs with Python?
|
|
|
|
What’s your strategy to handle schema evolution in Python ETL jobs?
|
|
|
|
How do you checkpoint or recover a failed ETL job in Python?
|
|
|
Edge Cases and Debugging Nightmares
|
|
|
|
Why can comparing two NaN values be tricky in Python?
|
|
|
|
What happens when you mutate a set while iterating over it?
|
|
|
|
What’s the output of [] is [], and why?
|
|
|
|
Why might a generator be exhausted unexpectedly?
|
|
|
|
What causes a RuntimeError: dictionary changed size during iteration?
|
|
|
Python Ecosystem Tools
|
|
|
|
What’s the role of pip-tools?
|
|
|
|
How do you freeze a requirements file for exact reproducibility?
|
|
|
|
Difference between virtualenv, venv, and conda?
|
|
|
|
What is Poetry and how is it better than pipenv?
|
|
|
|
How do you manage dependency conflicts in Python projects?
|
|
|
Packaging for Distribution
|
|
|
|
How do you bundle a Python CLI tool?
|
|
|
|
What is zipapp and how can it help?
|
|
|
|
How do you package and publish Python wheels?
|
|
|
|
What is a namespace package in Python?
|
|
|
|
What is twine used for?
|
|
|
APIs, Serialization, and Data Contracts
|
|
|
|
Difference between pydantic and marshmallow
|
|
|
|
How do you define a schema in FastAPI using Pydantic?
|
|
|
|
How do you validate nested schemas in Python?
|
|
|
|
How do you serialize and deserialize with pickle safely?
|
|
|
|
Why should pickle not be used over a network?
|
|
|
Soft Skills & Python Coding Practices
|
|
|
|
How do you write Python code that is easy to test?
|
|
|
|
How do you structure modules in a maintainable way?
|
|
|
|
What is Pythonic code?
|
|
|
|
How do you write documentation that scales with a Python project?
|
|
|
|
What are good code review practices for Python teams?
|
|
|
Python with AI/ML/DL Ecosystem
|
|
|
|
How do you serve a PyTorch or TensorFlow model via REST API?
|
|
|
|
What is the difference between joblib and pickle for model persistence?
|
|
|
|
What is ONNX and how do you use it in Python?
|
|
|
|
How do you write custom data loaders in PyTorch?
|
|
|
|
What’s your strategy for hyperparameter tuning with Python?
|
|
|
Python Security Deep Dive
|
|
|
|
How do you securely deserialize Python objects?
|
|
|
|
What are common Python vulnerabilities in web apps?
|
|
|
|
What is SSRF and how can it affect Python APIs?
|
|
|
|
How do you validate user inputs in Python web backends?
|
|
|
|
How do you prevent DoS attacks in Python-powered endpoints?
|
|
|
Download PDF
|
|