PYTHON
Programming Assignment #3 (40).
The structure of this program must be similar to the one in program 2
Start with the initial studGrades of assignment #2. DO NOT READ IT FROM A FILE (your grade will be 0/40 if you read from a file).
Your program will transform this table (each row of the table is a list) into a table where each row is s a dictionary. As an example, here is what the first two intial rows:
[ [1111 , “L” , “ART” ,”CC” , “Junior” , 3.5 , 7.8 , 4 , 2, 6],
[1256 , “L” , “MIS” ,”No” , “Soph” , 1.2 , 7.3 , 9.5 , 5, 10],
will become:
[{‘id’: 1111, ‘gradeType’: ‘L’, ‘major’: ‘ART’, ‘transfer’: ‘CC’, ‘year’: ‘Junior’, ‘gpa’: 3.5, ‘proj1’: 7.8, ‘proj2’: 4, ‘exam1’: 2, ‘exam2’: 6},
{‘id’: 1256, ‘gradeType’: ‘L’, ‘major’: ‘MIS’, ‘transfer’: ‘No’, ‘year’: ‘Soph’, ‘gpa’: 1.2, ‘proj1’: 7.3, ‘proj2’: 9.5, ‘exam1’: 5, ‘exam2’: 10}
All rows are dictionaries, all rows have the same keys, which are
‘id’ ‘gradeType’ ‘major’ ‘transfer’ ‘year’ ‘gpa’ ‘proj1’ ‘proj2’ ‘exam1’ ‘exam2’
This is a way to refer to an element of the table by its name (e.g. ‘gpa’) rather than its column number (we still need to provide its row # to identify it completely).
To get credit for this question, the tansformation described here must be done by your program, using loop(s).
Display the rows of the tables with values 1111, 1888, 3333 for the key ‘id’
Dictionaries, “Key” and “value” have speciific Python meaning.
Using the list of dictionaries, compute the average gpa. Compute how many students have their gpa greater than the average gpa. PRINT both results
Using the list of dictionaries, compute the number of students in each major and display.
Compute the average gpa for each major and display
Write a program to transform the list of dictionaries into a big dictionary (called big_New_Dict) . Display the new dictionary, in a very legible way
big_New_Dict = { 1111: {‘gradetype’:’L’, … ‘exam2’:6},
1256: {‘gradetype’:’L’, … ‘exam2’:10},
Using big_New_Dict, compute the average gpa. Compute the number of students in each major and display.
FORMATTING OF THE PROGRAM. Like Murach, page 343. However, do not use comments like “convert string to list”.
When you have a program well formatted using IDLE, it may happen that the good formatting disappear when you upload to canvas (this happens if your lines of code are long). This makes my work of understanding your program very hard. No credit for the questions where it happens.
Solution: rewrite with short lines of code, using explicit continuation (Murach, page 29).
That means: upload your work much before the deadline. Similarly, the execution output must be legible.