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

Exercise 3.3 (readscores.py). Download the file actsat.txt provided on Canvas. I

ID: 3705527 • Letter: E

Question

Exercise 3.3 (readscores.py). Download the file actsat.txt provided on Canvas. It contains the following columns of Column 1 2-letter state/territory code (includes DC) CSE/IT 1071. Lab 9: File and Column 2 % of graduates in that state taking the ACT Column 3 Average composite ACT score Column 4 % of graduates in that state taking the SAT Column 5 Average SAT Math score Column 6 Average SAT Reading score Column 7 Average SAT Writing score You must open this file and generate a list of dictionaries containing each row of data. Please use these keys for the dictionaries: "sat percent, taking "sat average nath "sat average reading state sat average vriting "act percent taking" For example, your code should process this two line file to form the following list of dictionaries 519 27 21.2 8 81 517 491 2 AL 20.3 9 556 563 554 state AK" act.percent taking 27 act average acore": 21.2 "sat percent, taking48 517 "sat average reading" 519 "sat average writing":491 "state": AK t percent taking 81 "act average score": 20.3 sat percent taking9 "t average math556 t average reading": 563 "at average uriting" 554

Explanation / Answer

lines = [line.rstrip(' ') for line in open('actsat.txt')]
res=[]
for line in lines:
values=lines.split()
dummy={
"state":values[0],
"act_percent_taking":values[1],
"act_average_score":values[2],
"sat_percent_taking":values[3],
"sat_average_math":values[4],
"sat_average_reading":values[5],
"sat_average_writing":values[6]
  
}
res.add(dummy)

The code is quite straight forward, I did not have the file. Please make appropriate changes.