## Lesson goal: Data Science: Find the average of numbers in a data file

Previous: Find the total of some numbers | Home | Next: Find the maximum value

As in the last lessons, suppose sample.dat contains a list of amounts spent by patrons during lunch at a retaurant. Let's see if we can tell the owner what their average earnings were. In other words, let's find the sum of all numbers in the file sample.dat, them divide by how many numbers there are. Average = (Sum of all numbers)/(total number of numbers), right? ${\bar x}=\frac{1}{N} \Sigma x_i$.

As is typical in such work, we'll need to set up a loop so we can examine each number in the file. But we won't just print them to the screen. We'll apply some coding logic to try and figure what the sum of all numbers in the file is, and how many numbers went into the sum.