An array is a linear data structure representations where data store in contiguous memory.
Scenario Questions
0-2 years experience
1How would you create a list containing the first ten square numbers in Python?
2If you try to assign a value to index 5 of an empty list, what error do you get and why?
3When would you prefer using the array.array type over a regular list for numeric data?
2-5 years experience
1We have a function that expects a list of integers but sometimes receives a tuple; how would you make the function robust?
2A bug shows that mutating a list inside a helper function also changes the caller's data. Explain why this happens and how to avoid it.
3For processing millions of floating‑point values, would you choose a list or array.array? Discuss the trade‑offs in speed and memory.
5-8 years experience
1Design a component that maintains a sliding window of the last N items from a high‑throughput stream. Which data structure would you pick and why?
2Compare the memory and runtime characteristics of storing a 10,000 × 10,000 matrix as a list of lists versus a flat list with manual index calculations.
3Our legacy code heavily uses the array module for numeric buffers. How would you refactor it to improve readability and performance while preserving behavior?
8+ years experience
1Our service keeps user activity logs in in‑memory arrays before persisting. As traffic scales, what architectural changes would you propose to keep latency low and memory usage predictable?
2When migrating a critical analytics pipeline from Python lists to NumPy ndarrays, what cross‑team compatibility and testing concerns arise?
3How would you establish organization‑wide guidelines for when to use built‑in list, array.array, or external libraries like NumPy, balancing performance, maintainability, and developer experience?
Follow-up Questions
Can you write a short snippet that demonstrates creating and mutating a list?
What pitfalls might you encounter when sharing a list between functions?
How does Python’s list implementation affect garbage collection?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.