Computer engineering · also Research methodsLevel 3 · Innovator
Lists, dictionaries and tabular data
A data structure organises many values so a program can find and change them efficiently. A Python list keeps items in order, reached by position starting from zero, and a slice takes part of it. A dictionary stores values under named keys, so a sensor record can hold its time, channel and reading by name rather than by a remembered position. Lists of dictionaries or lists of lists represent tables and grids, such as rows read from a CSV file or the cells of a map. The choice affects speed: checking whether an item is in a set or dictionary takes about the same time however large it grows, while searching a list takes longer as the list grows. Two names can also refer to one list, so changing it through either name changes both.
Why it mattersA robot's test log becomes easy to analyse once each row is a record with named fields instead of a line of loose numbers.