Infosys · engineering
Preparation guide for Python Developer positions at Infosys Technologies. Covers their InfyTQ / Hackwithinfy → Technical → HR process with technical, behavioral, and HR questions.
What is the difference between a list and a tuple in Python?
Tip: Lists are mutable, tuples are immutable. Tuples are faster and can be used as dictionary keys. Use tuples for fixed collections (coordinates, RGB), lists for data that changes.
What is the Global Interpreter Lock (GIL) in Python? How does it affect concurrency?
Tip: The GIL is a mutex that prevents multiple native threads from executing Python bytecode simultaneously, so threads cannot achieve true CPU parallelism in CPython. Workaround: use multiprocessing for CPU-bound tasks, asyncio for I/O-bound tasks.
Explain Python decorators. Write a simple logging decorator.
Tip: A decorator is a function that wraps another function to add behaviour without modifying it. Pattern: `def log(func): def wrapper(*args, **kwargs): print(func.__name__); return func(*args, **kwargs); return wrapper`. Use `functools.wraps` to preserve metadata.
What are Python generators? How do they differ from regular functions returning a list?
Tip: Generators use `yield` and are lazy — they produce one value at a time, keeping only the current state in memory. A function returning a list loads all values at once. Use generators for large datasets, infinite sequences, or pipelines.
What is the difference between `@staticmethod` and `@classmethod` in Python?
Tip: `@staticmethod` takes no implicit first argument — just a regular function namespaced in a class. `@classmethod` takes `cls` as first arg — it can access class state and is used for factory methods. Instance method takes `self` and can access both instance and class.
How does Django's ORM work? What is the N+1 problem in Django and how do you fix it?
Tip: Django ORM maps model classes to DB tables. N+1: querying related objects in a loop triggers one query per object. Fix with `select_related()` for ForeignKey (JOIN) or `prefetch_related()` for ManyToMany. Always check the Django debug toolbar query count.
What is a virtual environment in Python and why is it required?
Tip: A virtual environment isolates project dependencies so two projects can use different versions of the same package without conflict. Create with `python -m venv .venv`, activate, then `pip install`. Always commit `requirements.txt` or `pyproject.toml`.
Describe a Python script or service you built that solved a real business problem.
Tip: Quantify impact: "reduced report generation from 4 hours to 10 minutes." Mention libraries used, edge cases you handled, and how you tested it. Avoid generic "I built a CRUD app" — show problem-solving depth.
A Python web application is running slow. How do you identify and fix the bottleneck?
Tip: Profile first — never guess. Use `cProfile` or `py-spy` for CPU bottlenecks, Django debug toolbar for query issues. Common culprits: slow DB queries (missing index), serialisation overhead, or external API calls. Measure before and after any fix.
What is `*args` and `**kwargs`? When would you use them?
Tip: `*args` collects extra positional arguments as a tuple. `**kwargs` collects extra keyword arguments as a dict. Use when building wrappers/decorators or flexible APIs where the caller may pass an unknown number of arguments.
What is the difference between deep copy and shallow copy in Python?
Tip: Shallow copy creates a new container but nested objects are still shared references. Deep copy recursively copies all nested objects. Shallow copy trap: mutating a nested list in the copy also changes the original.
Django vs Flask vs FastAPI — when would you choose each for a new project?
Tip: Django: full-featured, admin panel, ORM, auth — best for data-heavy CRUD apps. Flask: lightweight, minimal, great for small APIs or prototypes. FastAPI: async-first, auto-generated OpenAPI docs, Pydantic validation — best for high-performance ML or data APIs.
Take a full scored mock interview tailored to your resume. Get feedback on technical depth, clarity, structure, confidence, and relevance — free to start.