''' DS2000 Fall 2024 Sample code from class - time series data for average admin assistant salaries in boston over time Our plan today: read in the file using a for loop with open(filename, "r") as infile: for line in infile: sal = float(line) (Remembering that sal will get overwritten over and over :) Computation for today: * What was the change in avg salary each year? ''' FILENAME = "asst_salaries.txt" def main(): # Initializing a variable to measure increases going foward, and # example of inside/outside the for loop! print("Hi I am outside the for loop and I happen ONCE, at the beginning!") previous_sal = 0 # Gather data - read from the file using a for loop! with open(FILENAME, "r") as infile: for line in infile: # Save the current line from the file as a float, # compute the increase compared to last year sal = float(line) incr = sal - previous_sal previous_sal = sal # Just printing to see examples :) print("this year's salary:", sal) print("incr:", incr, "\n") print("Hi I am outside the for loop so I happen ONCE, at the end!") main()