Part 04 / Topic 10 of 11
A note on the array module
Python has an array module. An array stores items of one type only (for example all ints), using a type code like "i".
from array import array # (imports are covered in Part 7)
readings = array("i", [10, 20, 30])
readings.append(40)
print(readings) # array('i', [10, 20, 30, 40])
print(readings[1]) # 20
Recommendation: for everyday code, use lists. They are simpler and more flexible. For heavy number work, later you will use NumPy (Stage 5, Part 18: data track).
Done here? The practice set for Part 4 — 8 exercises with solutions — is on the part page.