Arrays — Python Technical Interview Questions & Answers

Arrays

Arrays

  • array.array is a typed compact list (like 'i' for ints). Most freshers should use list. array is for memory when you have many numbers of one type.
  • Interview: list is general; array.array is typed. NumPy array is the data-science version — different library.
  • Arrays — output: 20 3. array('i') is typed ints. Daily work still uses list.

Technical Interview Tip: When list vs array.array vs NumPy.

Code Examples for Arrays

Example

# Arrays
from array import array
a = array("i", [10, 20, 30])
print(a[1], len(a))

Arrays — output: 20 3. array('i') is typed ints. Daily work still uses list.

How to Explain Arrays to an Interviewer

Explain Arrays as if you are teaching a junior — definition, then one tiny script.

Array.array = typed Daily work = list

What does the example print, and why?

Arrays — output: 20 3

What mistake do freshers make with Arrays?

NumPy = data science