Question
Write a program that reads from a text file students.txt student information of a given class and stores them into a list of dictionaries. Each
Write a program that reads from a text file "students.txt" student information of a given class and stores them into a list of dictionaries. 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) ofall students sorted in alphabetic order of their names
F: Find and display student information for a given student id (the user enters the student id)
L: List all the information ad. gpa and credits) of all students under probation (i.e. gpa < 2.0)
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 “student: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 list of dictionaries. Note that the information in the file is in increasing order of student id.
2. Menu (...): displays the menu and returns the user's choice
3. FindStudent (...): returns the position (index) of the student with given id, in the complex structure if found otherwise it returns -1.
4. DeleteStudentInfo (...): deletes from the complex structure 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. This function should use a binary search algorithm when searching for the student id.
5. PrintStudentinfo (...): prints all students' information in a tabular format.
6. SaveStudentInfo(...): saves back the modified students' information into the file students.txt. The students should be stored in increasing order of their id.
Additional Requirements:
1. You should display error message whenever it's possible
2. You should answer the following question: Could you use any of the following structures instead of a list of dictionaries. If no, why? If yes, indicate its advantages/disadvantages compared to a list of dictionaries?
a) A list of sets
b) A list of lists
c) Parallel lists
Step by Step Solution
3.41 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
import os import json class Student def initself selfstudentsdetailsNone selfmenudata Pprint the students informationnameidgpa and credits FFind and d...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
Document Format ( 2 attachments)
60950e6a74dfd_25502.pdf
180 KBs PDF File
60950e6a74dfd_25502.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started