Question: population.py Save the files named a USPopulation.txt from Module. This file contains the midyear population of the United States, in thousands, during the years 1

population.py
Save the files named a USPopulation.txt from Module. This file contains the midyear population of the United States, in thousands, during the years 1950 through 1990.
Write a program that reads the file's contents into a list. The program should display the following data:
The average annual change in population during the time period.
The year with the greatest increase in population during the time period.
The year with the smallest increase in population during the time period.
Hints
The program assumes that all population changes are positive. That is, that each year the population was larger than the previous year.
Define main ():
1. Open file for reading.
2. Read all the lines in the file into a list with readline method
3. Turn all read strings into numbers. //use a for loop with range function and len of the list
4. Calculate the change in population size for each two years. //another for loop with range function
5. If this is the first year, set trackers to its value.
6. Else this is not the first change in population size.
7. Calculate total_change and average_change
8. Display Average, greatest increase and smallest increase.
end main()
Expected output:
The average annual change in population during the time period is 2,443.88
The year with the greatest increase in population was 1955
The year with the smallest increase in population was 1967

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!