
What is PEP 8?
PEP 8 is the official style guide for writing Python code. It defines rules for code layout and best practices to improve readability.
What are Python decorators?
Decorators are a way to modify or extend the behavior of functions or classes without changing their source code directly.
Difference between @staticmethod
and @classmethod
?
A static method does not access class or instance data. A class method receives the class itself as its first argument and can access or modify class-level data.
What is Python’s GIL?
The Global Interpreter Lock (GIL) ensures only one thread executes Python bytecode at a time, which can limit true multithreading.
What are generators?
Generators are a way to create iterators that yield items one at a time, which is memory-efficient for large datasets.
How do you handle exceptions in Python?
Using try-except blocks to catch and handle errors gracefully, with optional finally blocks for cleanup.
What is a virtual environment?
A tool that creates an isolated Python environment for a project, keeping dependencies separate from the global installation.
How do you manage Python packages?
Using pip
to install, update, or uninstall packages, and using requirements.txt
to track dependencies.
What is WSGI?
Web Server Gateway Interface is a standard interface between Python web applications and web servers.
Difference between append
and extend
for lists?append
adds one element to a list; extend
adds all elements from another iterable to the list.
🚩 Django / Flask
How do you start a Django project?
By running Django’s built-in commands to create a project structure with settings and configuration files.
How do you start a Django app?
By creating an application inside a project, which encapsulates a part of the functionality (e.g., user management).
What is a Django model?
A Python class that defines the structure of a database table and how it interacts with the database.
How do you apply database migrations in Django?
By creating migration files when models change and then applying them to the database.
What are Django signals?
Signals allow decoupled applications to communicate when certain actions occur, like saving or deleting an object.
What are context processors?
Functions that add extra context variables to all templates automatically.
How does URL routing work in Django?
URL patterns in the project map specific paths to views that handle the request and return a response.
How do you handle file uploads?
By configuring models to store file data and setting up media settings to serve uploaded files.
What is a Flask Blueprint?
Blueprints help organize a Flask application into reusable modules or components.
How do you manage database migrations in Flask?
Using tools like Flask-Migrate, which provides database schema management for SQLAlchemy.
🚩 REST API
What is REST?
Representational State Transfer is an architectural style that uses standard HTTP methods to perform operations on resources.
What is the difference between PUT and PATCH?
PUT replaces an entire resource, while PATCH updates only specific fields of a resource.
What is JWT?
JSON Web Token is a compact, URL-safe token used to securely transmit information for authentication and authorization.
How do you test APIs in Django?
By using Django REST Framework’s test classes or tools like Postman to make requests and verify responses.
How do you serialize data in Django REST Framework?
Serializers convert complex Python objects (like querysets) into JSON format for API responses.
🚩 Database
What databases does Django support?
Popular options include SQLite (default), PostgreSQL, MySQL, and Oracle.
How do you optimize queries in Django?
By using query optimizations like selecting related objects to reduce the number of database hits.
What is an index in a database?
An index improves the speed of data retrieval by providing a quick lookup for rows matching certain criteria.
How do you run raw SQL in Django?
By executing direct SQL queries using Django’s database connection tools when ORM is insufficient.
Explain ACID properties.
ACID stands for Atomicity, Consistency, Isolation, and Durability — ensuring reliable processing of database transactions.
🚩 Frontend
What are the core frontend technologies?
HTML for structure, CSS for styling, and JavaScript for interactivity.
What is JSX?
JSX stands for JavaScript XML. It allows you to write HTML-like syntax in React components.
What are React Hooks?
Hooks are functions like useState
and useEffect
that let you manage state and side effects in functional React components.
Explain props vs state in React.
Props are read-only data passed to components. State is mutable data managed within the component.
What is a Single Page Application (SPA)?
An SPA loads a single HTML page and dynamically updates content without full page reloads.
How do you handle forms in React?
By binding form inputs to state and updating state on user input.
What is AJAX?
AJAX allows web pages to make asynchronous requests to the server without reloading the entire page.
What is XSS?
Cross-Site Scripting is an attack where malicious scripts are injected into trusted websites.
How do you prevent XSS?
By sanitizing input, using auto-escaping in templates, and applying Content Security Policies.
How do you manage global state in React?
By using tools like the Context API or external libraries such as Redux.
🚩 Fullstack & General
What is CORS?
Cross-Origin Resource Sharing is a security feature that controls which domains can access resources from your server.
What is Docker?
Docker is a platform for creating, deploying, and running applications in isolated containers.
What is CI/CD?
Continuous Integration and Continuous Deployment automate building, testing, and deploying applications.
How do you version an API?
By including a version number in the URL path or request headers.
What is OAuth?
OAuth is a standard for secure delegated access, allowing third parties to access user data without sharing passwords.
Difference between Monolithic and Microservices architecture?
Monolithic apps are single codebases, while microservices split functionality into independent, loosely-coupled services.
What is a reverse proxy?
A server that forwards client requests to backend servers, often used for load balancing or caching.
Explain Django’s MTV architecture.
MTV stands for Model, Template, View — similar to MVC but with different naming:
Model: database layer.
Template: presentation layer.
View: business logic.
How do you implement caching in Django?
By configuring a cache backend like Redis or Memcached to store computed results and reduce database hits.
How do you handle logging in production?
By configuring Python’s logging module or using third-party tools to record errors, track application behavior, and store logs securely.