And when you have lots of data to work with, using an individual variable for each piece of data gets really old, really quickly. So programmers employ some rather awesome containers (known as data structures) to help them work with lots of data. More times than not, all that data comes from a file stored on a hard disk. So, how can you work with data in your files? Turns out it's a breeze.
Surf's up in Codeville
Find the highest score in the results file
Iterate through the file with the open, for, close pattern
The file contains more than numbers...
Split each line as you read it
The splitQ method cuts the string
But you need more than one top score
Keeping track of 3 scores makes the code more complex
An ordered list makes code much simpler
Sorting is easier in memory
You can't use a separate variable for each line of data
An array lets you manage a whole train of data
Python gives you arrays with lists
Sort the array before displaying the results
Sort the scores from highest to lowest
You somehow forgot the surfer names
Your Programming Toolbox
132 136 139
hashes and databases Putting data in its place
Was this article helpful?