Python:Accumulate over a File with Multiple Variables
Calculate the average population size for the countries of the world.
Print the total population divided by the number of countries.
Recall that there are three steps:
- Declare and initialise your accumulators before the loop
totPop = 0 count = 0
- Increment the accumulator inside the loop.
totPop += pop count+=1
- Use the result - in this case print it, after the loop.
Is 3 million the median?
Show the number of countries with a population more than 3000000
Show the number of countries with a population less than 3000000