We have lots of functions.

We've already played with len and talked about len and

how many things are in the list.

We can say what's the largest number of a list?

What's the smallest number of a list?

Add them all up.

What's the sum of this list?

Sum of the list is 154 and you can calculate the average by the sum.

Now, some of you who will go back to Chapter 5 and

say, well why did you give us all those for

loops to do the same thing instead of just telling us this function?

So the answer is, well there are reasons for

knowing how to construct those for loops.

And they were good, easy-to-understand for loops.

If you have a list and

it's a list of numbers, these are far better than constructing a for loop.

So all those examples from that earlier chapter,

they're not the way you would do that particular problem.

But sometimes you're reading through lines in a file and

you have to do it a little bit differently.

So here's a couple of loops that sort of demonstrate this notion

of how you might use these functions to calculate an average versus

how we calculated an average in the earlier chapter.

Although I kind of redo this in a different way because now I'm pretending

I'm reading from a file but instead I'm going to read from input.

I'm going to read the numbers dot dot dot until I get a done.

And I'm going to calculate the average of those numbers.

And so it's just a standard loop where we set total to 0 and count to 0.

I'm going to make it a while loop, if I was reading a file it would be a for

loop but this is, I'm going to ask for some input, prompt it.

If it's done I'm going to break out of the loop so that handles this case,

so I can get out of the loop somehow.

And then I calculate the floating point value of that input, and

I add it to my running total, and I have my running count, count = count + 1.

And then this runs you know in this case three times, and then it comes down here,

and computes the average and prints it out, and away we go, okay?

And so that's kind of the manually constructed loop with a manually

constructed counter and a manually constructed sum and away you go.

Now, if I were try to use max and min to accomplish the exact same thing.