Page 15 -
P. 15
table of contents
hashes and databases
5 Putting data in its place
Arrays aren’t the only show in town when it comes to data.
Programming languages come with other data-arranging goodies too, and our
chosen tool, Python, is no exception. In this chapter, you’ll associate values
with names using a data structure commonly called the hash (better known as
dictionary to Python-folk). And when it comes to working with stored data, you’ll
read data from an external database system as well as from regular text-based
files. All the world’s awash with data, so turn the page and start applying your ever-
expanding programming skills to some cool data-processing tasks.
Who won the surfing contest? 146
Associate the name with the score 150
Associate a key with a value using a hash 153
Iterate hash data with for 154
The data isn’t sorted 158
When data gets complex 160
Return a data structure from a function 164
Here’s your new board! 168
Meanwhile, down at the studio... 169
The code remains the same; it’s the function that changes 170
TVN’s data is on the money! 174
Your Programming Toolbox 175
xiv