Python / Async Interview Questions 2026

Published July 22, 2026 · Updated July 22, 2026

32 Python / Async interview questions from Amazon, General, TCS, Google, Uber, Microsoft and more. Real questions from Technical, System Design, and HR rounds.

32 questions
Companies: Amazon, General, TCS, Google…

All Python / Async Questions

TCS Medium Screening round 1-3 years

Explain the difference between __repr__ and __str__. When is each called? Write a class where they return different things.

↑ 44 upvotes · 22 engineers asked this · SDE1
General Hard Scenario round 4-8 years

You're using Python multiprocessing and processes need to share a large dictionary (2GB) read-only. Creating copies per process uses 20GB total. How do you share memory efficiently?

↑ 43 upvotes · 21 engineers asked this · SDE2
TCS Medium Technical round 2-4 years

What are Python generators and when would you use them over lists? Implement a Fibonacci generator.

↑ 43 upvotes · 11 engineers asked this · SDE2
General Medium Scenario round 3-5 years

Your Python application has a function that should cache results but the @functools.lru_cache decorator is causing memory issues. Objects cached are large DataFrames. How do you implement a size-bounded cache?

↑ 42 upvotes · 40 engineers asked this · SDE2
General Medium Scenario round 2-4 years

Your Python service handles JSON data from multiple sources. Some send {'amount': '100.50'}, others send {'amount': 100.50}. Your code crashes intermittently when doing arithmetic. Fix this robustly.

↑ 42 upvotes · 20 engineers asked this · SDE2
General Hard Technical round 3-6 years

Your Python service deployed in Docker shows 10% more memory usage after each deployment with no code changes. What do you investigate?

↑ 42 upvotes · 10 engineers asked this · SDE2
General Hard System Design round 4-7 years

You're building a data pipeline in Python that processes streaming data. The pipeline has 5 stages. How do you ensure a failure in stage 3 doesn't lose data already processed by stages 1 and 2?

↑ 41 upvotes · 39 engineers asked this · SDE2
Amazon Hard Screening round 5-9 years

Explain Python metaclasses. When would you actually use one in production code?

↑ 41 upvotes · 19 engineers asked this · Staff
TCS Medium Screening round 1-4 years

What is the difference between @staticmethod and @classmethod in Python? Give use cases for each.

↑ 41 upvotes · 9 engineers asked this · SDE2
TCS Medium Technical round 2-5 years

A Django application using ORM makes 1 query per user in a list view. When the list has 500 users, the page makes 501 queries (1 for user list + 1 per user for their profile). Fix this with minimal code changes.

↑ 40 upvotes · 38 engineers asked this · SDE2
General Hard Technical round 3-6 years

Your Celery worker is processing tasks but tasks take 10 minutes each and the beat scheduler keeps adding duplicates because the first hasn't finished. Fix this.

↑ 40 upvotes · 18 engineers asked this · SDE2
Amazon Hard Screening round 3-6 years

Explain Python's garbage collector alongside reference counting. When does reference counting fail?

↑ 40 upvotes · 8 engineers asked this · SDE2
Amazon Hard Screening round 3-6 years

Explain Python's GIL. You have CPU-bound code that you parallelized with threading. It's not faster. Why? How do you actually make it faster?

↑ 39 upvotes · 37 engineers asked this · SDE2
General Hard Scenario round 3-6 years

You have a Python function that runs in 30 seconds. A profiler shows 90% of time is in one NumPy operation on a 10,000 x 10,000 matrix. How do you make it faster?

↑ 39 upvotes · 17 engineers asked this · SDE2
TCS Medium Technical round 2-5 years

Your Python scraper fails with 'SSL: CERTIFICATE_VERIFY_FAILED'. A colleague suggests verify=False. Why is that dangerous and what's the correct fix?

↑ 39 upvotes · 7 engineers asked this · SDE2
General Hard Scenario round 2-5 years

You have a Python script that processes 1 million records from a database. It loads all records into a list, processes each, then writes results. Memory usage hits 16GB and the OS kills it. Fix this without changing the database schema.

↑ 38 upvotes · 36 engineers asked this · SDE2
TCS Medium Screening round 2-4 years

Explain the difference between deepcopy and shallow copy in Python. Give a scenario where using shallow copy caused a bug.

↑ 38 upvotes · 16 engineers asked this · SDE2
Amazon Medium Technical round 2-5 years

Implement a Python decorator that retries a function up to N times with exponential backoff on specific exception types.

↑ 38 upvotes · 6 engineers asked this · SDE2
Amazon Hard Scenario round 3-6 years

Your Python FastAPI service handles 1000 requests/second. Adding one blocking I/O call (requests.get()) drops throughput to 50 requests/second. Why and how do you fix it without rewriting the service?

↑ 37 upvotes · 35 engineers asked this · SDE2
TCS Hard Technical round 3-6 years

Your Python service runs in Docker. On developer machines (Mac M1) it works fine. In production (Linux x86) it crashes with a C extension error. What's happening and how do you fix it?

↑ 37 upvotes · 15 engineers asked this · SDE2
General Hard Scenario round 3-6 years

Your Python code processes a 10GB JSON file. json.load() fails with MemoryError. How do you handle it?

↑ 37 upvotes · 5 engineers asked this · SDE2
Amazon Hard Screening round 4-8 years

Explain Python's descriptor protocol. How does @property use it? Write a descriptor that validates a positive integer.

↑ 36 upvotes · 14 engineers asked this · SDE2
General Hard Technical round 3-6 years

Your Python script takes 10 minutes to process 1 million CSV rows. Profile shows 80% time is in a string parsing function. Rewrite this function for maximum performance.

↑ 36 upvotes · 24 engineers asked this · SDE2
General Hard Screening round 3-6 years

What is Python's __slots__ and when would you use it? What are the trade-offs?

↑ 36 upvotes · 4 engineers asked this · SDE2
General Hard Scenario round 3-6 years

Your Django REST API has an endpoint that calls 3 external services sequentially, each taking ~500ms. Total response time is ~1.5 seconds. How do you parallelize these calls?

↑ 35 upvotes · 13 engineers asked this · SDE2
TCS Medium Technical round 2-5 years

Your Flask API crashes with 'RuntimeError: Working outside of application context.' When does this happen?

↑ 35 upvotes · 3 engineers asked this · SDE2
TCS Medium Technical round 2-5 years

Write a Python context manager for a database transaction that commits on success and rolls back on exception.

↑ 34 upvotes · 52 engineers asked this · SDE2
Google Medium Technical round 2-5 yearsPython

You have a 50GB CSV file and only 8GB of RAM. Walk through how you would compute the average of one column using pandas without crashing the process.

↑ 33 upvotes · 19 engineers asked this · Data Scientist
Uber Medium Technical round 3-6 yearsPythonSystem Design

You need to find all available drivers within a 3km radius of a rider efficiently, with millions of driver location updates per second. What indexing structure would you use and why not a naive distance calculation over all drivers?

↑ 32 upvotes · 15 engineers asked this · Senior SDE
Amazon Medium Technical round 2-5 yearsPython

Explain how Python's dictionary achieves average O(1) lookup. What happens internally when two keys hash to the same bucket?

↑ 22 upvotes · 14 engineers asked this · SDE2
General Medium Technical round 1-4 yearsPython

What is the difference between .loc[] and .iloc[] in pandas? Give an example where using the wrong one silently returns the wrong row.

↑ 22 upvotes · 13 engineers asked this · Data Scientist
Microsoft Medium Technical round 2-5 yearsPython

Write a Python decorator @timed that prints how long a function took to execute, and explain how functools.wraps prevents it from breaking introspection.

↑ 20 upvotes · 11 engineers asked this · Senior SDE

Practice these questions with AI feedback

Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.

Build my study plan →

Same topic at specific companies

Amazon Python / Async General Python / Async TCS Python / Async Google Python / Async Uber Python / Async Microsoft Python / Async

Related topics

DSA / Arrays System Design DSA / Trees DSA / Graphs Behavioral Testing Domain DevOps API Testing DSA / Hashmaps GCP / Real-time Data Java / Pub-Sub React / Performance Node.js / Memory SQL / Query Optimization AWS / Lambda Kafka / Consumer Microservices / Saga Pattern TypeScript / Type System MongoDB / Indexing Security / SQL Injection Performance / Latency Tail Redis / Cache Stampede Elasticsearch / Cluster Health GraphQL / Security Data Engineering / Exactly Once Snowflake / Architecture PySpark / Core Concepts Airflow / Scheduling Web / WebAssembly Debugging / Production JavaScript / V8 Engine

Frequently asked questions

Explain the difference between __repr__ and __str__. When is each called? Write a class where they return different things.
Explain the difference between __repr__ and __str__. When is each called? Write a class where they return different things.
You're using Python multiprocessing and processes need to share a large dictionary (2GB) read-only. Creating copies per process uses 20GB total. How do you share memory efficiently?
You're using Python multiprocessing and processes need to share a large dictionary (2GB) read-only. Creating copies per process uses 20GB total. How do you share memory efficiently?
What are Python generators and when would you use them over lists? Implement a Fibonacci generator.
What are Python generators and when would you use them over lists? Implement a Fibonacci generator.
Your Python application has a function that should cache results but the @functools.lru_cache decorator is causing memory issues. Objects cached are large DataFrames. How do you implement a size-bounded cache?
Your Python application has a function that should cache results but the @functools.lru_cache decorator is causing memory issues. Objects cached are large DataFrames. How do you implement a size-bounded cache?
Your Python service handles JSON data from multiple sources. Some send {'amount': '100.50'}, others send {'amount': 100.50}. Your code crashes intermittently when doing arithmetic. Fix this robustly.
Your Python service handles JSON data from multiple sources. Some send {'amount': '100.50'}, others send {'amount': 100.50}. Your code crashes intermittently when doing arithmetic. Fix this robustly.