Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a .txt a file named USPopulation.txt. The file contains the midyear popul

ID: 3666088 • Letter: I

Question

I have a .txt a file named USPopulation.txt. The file contains the midyear population of the United States, in thousands, during the years 1950 through 1990. The first line in the file contains the population for 1950, the second line contains the population for 1951, and so forth. Create an application in C# that reads the file’s contents into an array or a List. The application 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 least increase in population during the time period

(Any and all help is appreciated. I am not sure how to post the USPopulation.txt file)

Thank you for your time.

Explanation / Answer

def main(): #setup variables yearly_change = [] change=0.0 total_change=0 average_change=0 greatest_increase=0 smallest_increase=0 greatest_year=0 smallest_year=0 BASE_YEAR=1950 try: #open the file for reading input_file = open("USPopulation.txt", "r") #read all the lines in the in file into a list yearly_population= input_file.readlines() #turn all read lines into a number for i in range(len(yearly_population)): yearly_population[i] = float(yearly_population[i]) #calculate the change in population size for each two years for i in range(1,len(yearly_population)): change = yearly_population[i] - yearly_population[i-1] #MISSING SINGLE LINE HERE? #if this is the first year, set trackers to its value if i==1: greatest_increase = change smallest_increase = change greatest_year = 1 smallest_year = 1 #this is not the first change in population size #update the trackers if relevent else: if change>greatest_increase: greatest_increase = change greatest_year = i elif change