Question: import matplotlib.pyplot as plt def read_students (filename) : Reads the student records from the given CSV file. Returns four dictionaries: 1. the key is

import matplotlib.pyplot as plt def read_students(filename): """ Reads the student records from the given CSV file. Returns four dictionaries: 1. the key is the ID and the values are individual student records 2. the key is the major (lowercase) and the values are lists of student records 2. the key is the year (lowercase) and the values are lists of student records 2. the key is the advisor (lowercase) and the values are lists of student records Each student record has an ID (int), name, major, year, and advisor. None of these values have been changed except ID is converted to an int (i.e. non have been lowercased). """ return {}, {}, {}, {} #TODO def get_valid_id_from_user(ids): """ Gets a valid ID from the user. A valid ID is a bunch of digits and, once converted to an int, is one of the elements in the given set of ids. This function returns an integer. Example when given the set of ids [100, 101, 102, 103, 104, 105]: Enter a student ID: apple Not a valid ID, try again: 5 Not a valid ID, try again: 100 And then it returns 100 as an integer. """ return 0 # TODO: remove this line and write your code def get_valid_value_from_user(allowed, name): """ Gets a valid value from the user. The input must be in the set of allowed values given as an argument. All of the allowed options have already been converted to lowercase and the user's input should be as well. The prompt to the user includes the given name argument. Example when given the allowed values ['freshman', 'sophomore', 'junior', 'senior'] and the name 'class year': Enter a class year: apple Not a valid class year, try again: FRESHMAN And then it returns 'freshman'. """ return '' # TODO: remove this line and write your code def print_information_for_student(student_record): """ Prints out the information from a student record. A student record is a list of a single student's ID (as an integer), name, major, year, and advisor. Returns nothing. The print out should be like: Student #100: Anthony Quinn in major Biology in Sophomore year with advisor Jeffrey Bush """ pass # TODO: remove this line and write your code def print_list_of_students(student_records): """ Prints out the ID and name of the students in the list. The student records contain a lot of information, but the first two values in each record are the ID and the name. Returns nothing. The print out should be like: 100 Anthony Quinn 101 Stephen Hawking 102 George Washington """ pass # TODO: remove this line and write your code def get_lengths(collection): """ Returns a list of the lengths of each of the values of the elements in the given collection. """ return [] # TODO: remove this line and write your code def convert_all_to_title_case(collection): """ Returns a list containing all of the elements in the given collection but after calling the title() method for each of them. NOTE: the title() method is like the upper() or lower() methods and changes capitalization by making the first letters uppercase. """ return '' # TODO: remove this line and write your code def bar_plot_len_of_values(dictionary): """ Makes a bar plot with the keys of the dictionary as the x-ticks and the Y values are the lengths of each of the values of the items in the dictionary. """ # Get the X ticks values and the Y values X = convert_all_to_title_case(dictionary.keys()) Y = get_lengths(dictionary.values()) # TODO: make the bar plot plt.xticks(rotation=90) # rotates the x-ticks by 90 degrees plt.subplots_adjust(bottom=0.35) # makes room for the x-ticks plt.show() def main(): # Load the data students_by_id, students_by_major, students_by_year, students_by_advisor = read_students('students.csv') # Continue until the user chooses to quit quitting = False while not quitting: # Show the menu print('---------------------------------------') print('MENU') print('1. List of Grades for Student Given ID') print('2. List Students for Major') print('3. List Students for Class Year') print('4. List Students with Advisor') print('5. Plot Number of Students per Major') print('6. Plot Number of Students per Class Year') print('7. Plot Number of Students per Advisor') print('8. Quit') print('---------------------------------------') # Get the user's choice and then do the appropriate action choice = input('Enter your menu choice: ') if choice == '1': student_id = get_valid_id_from_user(students_by_id.keys()) print_information_for_student(students_by_id[student_id]) elif choice == '2': major = get_valid_value_from_user(students_by_major.keys(), 'major') print_list_of_students(students_by_major[major]) elif choice == '3': year = get_valid_value_from_user(students_by_year.keys(), 'class year') print_list_of_students(students_by_year[year]) elif choice == '4': advisor = get_valid_value_from_user(students_by_advisor.keys(), 'advisor') print_list_of_students(students_by_advisor[advisor]) elif choice == '5': bar_plot_len_of_values(students_by_major) elif choice == '6': bar_plot_len_of_values(students_by_year) elif choice == '7': bar_plot_len_of_values(students_by_advisor) elif choice == '8': quitting = True else: print('Invalid choice, please try again') print('Bye!') if __name__ == "__main__": main() 

This is the CSV file:

101,Iain Austin,Accounting,Freshman,Kayley Jaramillo 102,Kirandeep Carpenter,Accounting,Sophomore,Parris Olsen 103,Rian Roach,Accounting,Junior,Elspeth Greig 104,Brent Cruz,Accounting,Senior,Tyson Flowers 105,Ayva Person,Art,Freshman,Ruben Whelan 106,David Spooner,Art,Sophomore,Kayley Jaramillo 107,Amarah Pitts,Art,Junior,Parris Olsen 108,Debbie Waller,Art,Senior,Elspeth Greig 109,Ishika Colley,Art,Freshman,Tyson Flowers 110,Virgil Mayo,Biochemistry,Sophomore,Ruben Whelan 111,Haydon Guevara,Biochemistry,Junior,Kayley Jaramillo 112,Asiya Orr,Biochemistry,Senior,Parris Olsen 113,Dustin Klein,Biochemistry,Freshman,Ruben Whelan 114,Marwa Griffiths,Biology,Sophomore,Tyson Flowers 115,Raees Sweet,Biology,Junior,Ruben Whelan 116,Iylah Pineda,Biology,Senior,Kayley Jaramillo 117,Fallon Calvert,Biology,Freshman,Parris Olsen 118,Charity Crouch,Biology,Freshman,Elspeth Greig 119,Flynn Mccallum,Biology,Junior,Tyson Flowers 120,Kamron Beck,Chemistry,Senior,Ruben Whelan 121,Shoaib Rogers,Chemistry,Freshman,Kayley Jaramillo 122,Elara Williamson,Chemistry,Sophomore,Parris Olsen 123,Veer Grainger,Chemistry,Junior,Elspeth Greig 124,Ksawery Thompson,Computer Science,Senior,Tyson Flowers 125,Patsy Nichols,Computer Science,Freshman,Elspeth Greig 126,Cathy Hale,Computer Science,Sophomore,Elspeth Greig 127,Patience Trujillo,Computer Science,Junior,Parris Olsen 128,Desiree Kent,Computer Science,Senior,Elspeth Greig 129,Azaan Miles,Computer Science,Freshman,Tyson Flowers 130,Layla Larson,Economics,Sophomore,Ruben Whelan 131,Asif Herman,Economics,Junior,Dean Humphries 132,Tyreece Maldonado,Economics,Junior,Romana Corona 133,Dainton Watkins,Economics,Freshman,Sahib Vincent 134,Aayush Le,Economics,Sophomore,Bradleigh Dalton 135,Veronica Bowers,Education,Junior,Dulcie Dennis 136,Rikesh Vinson,Education,Senior,Dean Humphries 137,Mitchell Cornish,Education,Freshman,Romana Corona 138,Summer Decker,English,Sophomore,Bradleigh Dalton 139,Bessie Alcock,English,Junior,Bradleigh Dalton 140,Ciara Holman,English,Senior,Dulcie Dennis 141,Wilma Gibbons,Environmental Science,Freshman,Romana Corona 142,Tudor Li,Environmental Science,Sophomore,Romana Corona 143,Kylie Sandoval,Environmental Science,Junior,Romana Corona 144,Hajrah Tate,French,Sophomore,Bradleigh Dalton 145,Rafi Washington,German,Freshman,Dulcie Dennis 146,Saoirse Palacios,Health Sciences,Sophomore,Dean Humphries 147,Cherish Wagstaff,Health Sciences,Junior,Romana Corona 148,Andrea Gonzalez,Health Sciences,Sophomore,Sahib Vincent 149,Raiden Ochoa,Health Sciences,Freshman,Bradleigh Dalton 150,Robin Davie,Health Sciences,Sophomore,Dulcie Dennis 151,Codie Anderson,Health Sciences,Junior,Percy Caldwell 152,Huma Coleman,History,Senior,Kishan Macias 153,Giles Peters,History,Freshman,Kishan Macias 154,Ibrahim Hester,Management,Sophomore,Krishan Lacey 155,Macey Metcalfe,Management,Junior,Chandni Witt 156,Dominic Bryant,Management,Senior,Percy Caldwell 157,Fathima Fritz,Management,Freshman,Kishan Macias 158,Calista Emery,Management,Sophomore,Payton Mellor 159,Maariya Bailey,Mathematics,Junior,Krishan Lacey 160,Ieuan Schneider,Mathematics,Senior,Chandni Witt 161,Zayden Jimenez,Mathematics,Freshman,Percy Caldwell 162,Rosalie Osborn,Music,Sophomore,Kishan Macias 163,Conan Alfaro,Music,Junior,Payton Mellor 164,Glyn Murray,Music,Senior,Krishan Lacey 165,Madina Harrison,Music,Freshman,Chandni Witt 166,Mahdi Shepard,Neuroscience,Sophomore,Percy Caldwell 167,Usmaan Macfarlane,Neuroscience,Junior,Kishan Macias 168,Izzy Mcintosh,Neuroscience,Senior,Payton Mellor 169,Sean Vu,Neuroscience,Freshman,Krishan Lacey 170,Billie-Jo Knapp,Neuroscience,Sophomore,Chandni Witt 171,Mohsin Gilbert,Nursing,Junior,Percy Caldwell 172,Arley Bradshaw,Nursing,Senior,Kishan Macias 173,Tobias Lee,Nursing,Freshman,Payton Mellor 174,Madelyn Roy,Nursing,Sophomore,Krishan Lacey 175,Giuseppe Delaney,Nursing,Junior,Chandni Witt 176,Santiago Mcdowell,Nursing,Senior,Edith Travis 177,Leanne Zamora,Nursing,Freshman,Edith Travis 178,Aden Cooke,Nursing,Sophomore,Renee Hartley 179,Alexie Schultz,Nursing,Junior,Christopher Burks 180,Darla George,Philosophy,Senior,Kloe Becker 181,Mildred Carlson,Philosophy,Freshman,Haleema Wolfe 182,Enrico Mckee,Physics,Sophomore,Edith Travis 183,Zaynah Goldsmith,Physics,Junior,Renee Hartley 184,Bradlee Markham,Physics,Senior,Christopher Burks 185,Nimra Wood,Political Science,Freshman,Kloe Becker 186,Darryl Paine,Political Science,Sophomore,Haleema Wolfe 187,Zidane Collins,Political Science,Junior,Edith Travis 188,Darrel Ireland,Psychology,Senior,Edith Travis 189,Keavy Whitehouse,Psychology,Freshman,Edith Travis 190,Nazia Bruce,Psychology,Sophomore,Kloe Becker 191,Elissa Ward,Psychology,Junior,Lucy Mccabe 192,Ziggy Drake,Psychology,Senior,Tonicha Mccarthy 193,Kendrick Harmon,Public Health,Freshman,Amber Mccann 194,Devon Smart,Public Health,Sophomore,Alister Mathews 195,Meera Barry,Public Health,Junior,Fox Alvarado 196,Findlay Kim,Public Health,Senior,Lucy Mccabe 197,Jannat Odling,Public Health,Freshman,Tonicha Mccarthy 198,Jeevan Mcintyre,Public Health,Sophomore,Amber Mccann 199,Iestyn Eaton,Public Health,Junior,Alister Mathews 200,Evie-Grace Lam,Religion,Senior,Fox Alvarado 201,Serena Mccabe,Sociology,Freshman,Amber Mccann 202,Milton Page,Sociology,Sophomore,Amber Mccann 203,Tonisha Beil,Sociology,Junior,Amber Mccann 204,Matt Harrington,Spanish,Senior,Alister Mathews 205,Emilia Riddle,Spanish,Freshman,Fox Alvarado 

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!