Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started