Amazon | Python Developer / SDE

Amazon Python Interview Questions

Amazon Python interviews combine LeetCode-style DSA, OOP principles, AWS Lambda integration, and Leadership Principles scenarios. SDE roles focus on clean, testable code with edge case handling. Expect 4-5 rounds with behavioral questions in every round.

30+
Real Questions
2026
Updated
AI
Live Practice
Foundation Questions - Guaranteed to Appear
1
Implement a LRU (Least Recently Used) Cache in Python.
from collections import OrderedDict class LRUCache: def __init__(self, capacity): self.cache = OrderedDict(); self.capacity = capacity def get(self, key): if key not in self.cache: return -1 self.cache.move_to_end(key) return self.cache[key] def put(self, key, value): if key in self.cache: self.cache.move_to_end(key) self.cache[key] = value if len(self.cache) > self.capacity: self.cache.popitem(last=False) O(1) for both get and put. OrderedDict maintains order, move_to_end marks recent use, popitem(last=False) evicts the oldest.
2
What are Python decorators? Write a timing decorator.
Decorators wrap a function to extend behavior without modifying it — implementing the Open/Closed Principle. import time from functools import wraps def timer(func): @wraps(func) def wrapper(*args, **kwargs): start = time.perf_counter() result = func(*args, **kwargs) print(f'{func.__name__} took {time.perf_counter()-start:.4f}s') return result return wrapper @wraps preserves the original function's __name__ and __doc__ — Amazon interviewers ask about this specifically.
3
Explain Python's GIL and its impact on Amazon high-throughput services.
The GIL (Global Interpreter Lock) allows only one thread to execute Python bytecode at a time, even on multi-core machines. For I/O-bound tasks (S3 reads, API calls), threading works well because the GIL is released during I/O waits. For CPU-bound tasks (data processing, ML inference), use the multiprocessing module (bypasses GIL), NumPy C extensions, or AWS Lambda concurrent invocations for horizontal scale.
4
How would you process files from S3 efficiently in Python?
import boto3 from concurrent.futures import ThreadPoolExecutor s3 = boto3.client('s3') def process_object(key): obj = s3.get_object(Bucket='my-bucket', Key=key) data = obj['Body'].read().decode('utf-8') return key paginator = s3.get_paginator('list_objects_v2') keys = [obj['Key'] for page in paginator.paginate(Bucket='my-bucket') for obj in page.get('Contents', [])] with ThreadPoolExecutor(max_workers=20) as executor: results = list(executor.map(process_object, keys)) Key points: Use paginators for buckets with more than 1000 objects. ThreadPoolExecutor for I/O-bound S3 reads. Use Range header for chunked streaming of large files.
5
What is the difference between *args and **kwargs? Give an Amazon example.
*args collects positional arguments as a tuple. **kwargs collects keyword arguments as a dict. Order processor example: def process_order(order_id, *items, **options): if options.get('priority'): rush_process(order_id) if options.get('gift_wrap'): add_gift_wrap(order_id) process_order('ORD-001', 'laptop', 'charger', priority=True, gift_wrap=False) At Amazon, this pattern powers flexible API interfaces where optional fields vary per product category. *args must appear before **kwargs in the function signature.
6
Find all anagram groups in a list of words — Amazon DSA question.
from collections import defaultdict def group_anagrams(words): groups = defaultdict(list) for word in words: key = tuple(sorted(word)) groups[key].append(word) return list(groups.values()) # Example: group_anagrams(['eat','tea','tan','ate','nat','bat']) # Output: [['eat','tea','ate'],['tan','nat'],['bat']] Time: O(N * K log K). Amazon follow-up: use tuple of 26 character count frequencies as key for O(N*K) solution.

Practice With Live AI Interview Simulator

GhostMode AI simulates real Amazon interviewers - ask follow-ups, get scored, and receive feedback on your answers in real-time.

Start AI Mock Interview Start Free Prep