Python & Flask-Based Questions
1. What are the key differences between Python 2 and Python 3?
• Python 3 is the future and Python 2 is no longer supported since 2020.
• Print is a function in Python 3 (print()) but a statement in Python 2 (print "text").
• Integer division returns float in Python 3, while it returns integer in Python 2.
• Unicode is the default string type in Python 3.
• Better exception handling in Python 3 (except Exception as e:).
2. Explain the concept of decorators in Python.
• Decorators are functions that modify the behavior of other functions.
• Useful for logging, authentication, caching, etc.
• Example:
def decorator(func):
def wrapper():
print("Before function")
func()
print("After function")
return wrapper
@decorator
def say_hello():
print("Hello")
3. What is Flask, and how does it differ from Django?
• Flask is a lightweight micro-framework.
• Django is a full-fledged web framework (batteries-included).
• Flask offers more flexibility and customization.
• Django includes ORM, admin, and many built-in features.
4. How does Flask handle routing?
• Flask uses decorators to bind URLs to Python functions.
@app.route("/home")
def home():
return "Welcome to Home"
5. How do you handle form data and file uploads in Flask?
• Use request.form to access form fields.
• Use request.files to handle file uploads.
file = request.files['file']
file.save("path/to/save")
6. What is WSGI and why is it important in Flask applications?
• WSGI (Web Server Gateway Interface) is a specification for Python web applications.
• It allows Flask apps to communicate with web servers (e.g., Gunicorn, uWSGI).
7. How do you implement authentication and authorization in Flask?
• Use Flask-Login for session-based login.
• Use Flask-JWT for token-based authentication.
• Restrict routes with decorators like @login_required.
8. Explain the use of Blueprints in Flask.
• Blueprints allow modular structuring of a Flask app.
• You can split app routes and logic across multiple files.
9. How do you manage database migrations in Flask applications?
• Use Flask-Migrate with SQLAlchemy.
• Commands: flask db init, flask db migrate, flask db upgrade.
Frontend (React.js, JavaScript, HTML/CSS)
10. What are React hooks? Explain useState and useEffect with examples.
• Hooks allow functional components to use state and lifecycle.
• useState manages state.
• useEffect performs side effects.
const [count, setCount] = useState(0);
useEffect(() => { console.log(count); }, [count]);
11. What is the virtual DOM in React and how does it work?
• Virtual DOM is a lightweight in-memory representation of the real DOM.
• React updates only changed parts of the real DOM for better performance.
12. What is the difference between controlled and uncontrolled components in React?
• Controlled: Form data is handled by React state.
• Uncontrolled: Form data is handled by the DOM.
13. Explain how React and Flask can be integrated in a single project.
• Use Flask for backend APIs.
• Use React for frontend UI.
• Serve React from Flask using send_from_directory() or run them separately and connect via API.
14. What are props and state in React?
• Props: Passed from parent to child, read-only.
• State: Local component data, can be updated.
15. Explain Redux and how it manages state in a React app.
• Redux is a state container.
• It uses a single store, actions, and reducers.
• Helps in predictable state management.
16. What are some key features of ES6 that you’ve used?
• Arrow functions
• Let/Const
• Template literals
• Destructuring
• Spread/rest operator
• Promises and async/await
17. How do you handle form validation in React?
• Manually using state and conditions.
• Using libraries like Formik + Yup.
18. What is Material-UI and how do you apply themes using it?
• React UI library for styling components.
• Use ThemeProvider and createTheme to define and apply themes.
Database (SQL, SQLAlchemy, ORM)
19. What are the differences between SQL and NoSQL databases?
• SQL: Relational, structured, uses tables (e.g., MySQL).
• NoSQL: Non-relational, flexible schema (e.g., MongoDB).
20. Write a SQL query to get the second highest salary from an employee table.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
21. What is SQLAlchemy? How do you define models and relationships in it?
• ORM for Python.
• Maps Python classes to DB tables.
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
22. How do you use raw SQL queries in SQLAlchemy?
result = db.session.execute("SELECT * FROM users")
23. Explain connection pooling and how it improves database performance.
• Reuses DB connections instead of creating new ones.
• Reduces overhead, improves performance.
APIs and Microservices
24. What is REST API? What are its key principles?
• REST = Representational State Transfer.
• Stateless, client-server, uniform interface, cacheable.
25. How do you create and consume REST APIs in Flask?
• Use @app.route with methods.
• Use requests library to consume APIs.
26. How do you handle request validation and error handling in Flask APIs?
• Use Marshmallow or manual checks.
• Return structured JSON errors using abort or custom response.
27. How do you ensure security in APIs (Authentication tokens, CORS, rate limiting)?
• JWT tokens for auth.
• Enable CORS using Flask-CORS.
• Use Flask-Limiter for rate limiting.
28. What are microservices? What are their benefits and challenges?
• Independent deployable services.
• Benefits: scalability, isolation.
• Challenges: communication, data consistency.
29. How do you design a microservice-based architecture using Flask and React?
• Each Flask service handles a specific task.
• Use REST APIs for communication.
• React frontend connects to multiple Flask microservices.
DevOps & Deployment
30. What is Docker and how have you used it in your projects?
• Containerization platform.
• Used to create isolated environments for apps.
31. What is the purpose of Docker Compose?
• Define multi-container apps.
• Use a YAML file to start DB + API + frontend together.
32. Explain how to deploy a Flask app on Azure App Services or a VM.
• Use Azure CLI or Portal.
• Push code to Azure, set environment, run using Gunicorn.
33. What are Nginx and Gunicorn used for in a production Flask app?
• Gunicorn: WSGI HTTP server to run Flask.
• Nginx: Reverse proxy, handles static files, load balancing.
34. Explain how to configure GitHub actions or CI/CD for deploying a Python app.
• Use .github/workflows YAML file.
• Define build, test, deploy steps.
Other Technical Concepts
35. What is multithreading in Python? How does GIL affect it?
• Multiple threads in same process.
• GIL (Global Interpreter Lock) allows only one thread at a time in CPython.
36. How do you log events in a Python application?
• Use logging module.
import logging
logging.info("Info message")
37. What are schedulers and how do you implement task scheduling in Python?
• Automates tasks (e.g., cron jobs).
• Use APScheduler or Celery + Redis.
38. How do you send emails from a Python app?
• Use smtplib or Flask-Mail.
server = smtplib.SMTP('smtp.gmail.com', 587)
39. What is openpyxl and how do you use it to read/write Excel files?
• Python library to work with .xlsx files.
wb = openpyxl.load_workbook('file.xlsx')
40. How do you handle large data sets using Pandas efficiently?
• Use chunksize while reading.
• Drop unused columns.
• Use categorical data types.
Behavioral & Soft Skills
41. Describe a challenging bug you faced and how you resolved it.
• Faced memory leak in data processing.
• Used profiling tools and fixed inefficient loops.
42. Have you worked directly with clients or cross-functional teams? Explain.
• Yes, worked with design and QA teams to finalize UI and features.
43. How do you manage your time when working on multiple modules/features?
• Use tools like Jira.
• Prioritize based on deadlines.
• Follow Agile sprints.
44. Explain a time when you suggested an improvement in the project.
• Suggested caching API responses.
• Reduced load time significantly.
45. How do you ensure code quality and readability in a team project?
• Use linters (flake8), code reviews, documentation.
• Follow PEP8.
Optional HR/General Questions
46. Why do you want to work at Corbus?
• Innovative projects and learning opportunities.
• Strong technology stack and supportive culture.
47. What are your short-term and long-term goals as a Python developer?
• Short: Become a full-stack developer.
• Long: Lead projects and contribute to architecture.
48. How do you stay updated with new technologies?
• Follow blogs (RealPython), GitHub, attend webinars.
49. Are you comfortable working in a SCRUM/Agile environment?
• Yes, I have experience in sprint planning, standups, retrospectives.
50. Do you prefer working in a team or independently? Why?
• Comfortable with both.
• Team: Collaboration and shared learning.
• Independent: Focus and ownership.