Question: Write a python program that reads from a text file students.txt student information of a given class and stores them into a dictionary of lists.
Write a python program that reads from a text file students.txt student information of a given class and stores them into a dictionary of lists. Each line of the file contains a student id (integer), a student name, a student gpa (float), and the number of completed credits (integer). The program should then display the menu shown below allowing the user to select repeatedly an option until he or she chooses to quit:
P: Print the student information (name, id, gpa and credits) of all students sorted in increasing order of their ids
F: Find and display student information for a given student id (the user enters the student id)
L: List all the information (id, gpa and credits) of all students under probation (i.e. gpa < 2.0) in decreasing
order of their gpas
D: Delete the student information for a given student id (the user enters the student id)
E Exit the program after saving into the file students.txt the modifications made during the session
Your program must define and use at least the following functions with suitable parameters:
1. readStudentInfo (...): reads the student information from the input file and stores it in the dictionary of lists.
2. menu (...): displays the menu and returns the users choice
3. findStudent (...): returns the information of the student with a given id, if found otherwise it returns an empty list.
4. deleteStudentInfo (...): deletes from the dictionary of lists the information of a student with the given id. If the given
student id is not found, it prints an error message and does not make any changes.
5. printStudentInfo (...): prints all students information in a tabular format.
6. listProbations(...): prints information of students under probations in decreasing order of their gpas
7. saveStudentInfo(...): saves back the modified students information into the file students.txt.
Additional Requirements:
1. You should display error message whenever its possible
2. You should show using a diagram how an appropriate data structure looks like when it consists of:
a) A list of sets
b) A list of lists
c) Parallel lists
d) A list of dictionaries
e) A dictionary of lists
f) A set of lists
g) A set of dictionaries
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
