Question
PLEASE HELP ME Please read all requirements before you answer. In Python, Create a program that manages a text file containing student records. Each record
PLEASE HELP ME Please read all requirements before you answer.
In Python, Create a program that manages a text file containing student records. Each record will contain a student name and 3 exam scores. Each field in a record is separated by a comma (no space), and the name is given as first name, a space, then last name. Here are 3 example records. Students.txt
linda tyler,76,72,88
dave smith,72,91,75
steve davis,88,92,84
Program needs to use a menu to allow the user to select one of 4 choices(see below).
Menu options. Choose 1, 2, 3, or 4
1. Display student names and scores
2. Add a new student.
3. Display exam averages
4. Save and exit
Enter your choice : 1, 2, 3, or 4:
Program needs to start in a main() function where it will read the data from a file into a dictionary. This dictionary will hold all of the student records.
After loading the records from the file, the dictionary will have entries that have each student's name as a key, and the value associated with this key will be a list of integers containing the student's 3 exam scores. So, using first example record listed earlier, if the first record read was linda tyler and this code reads the file then the effect here would be to assign "linda tyler" as a key in the students dictionary, and have linda's 3 integer scores stored as a list to be the value associated with that key. It would be equivalent to this.
students["linda tyler"] = [76, 72, 88]
Each menu option should call a separate function, and here is what the options in the menu should do.
If you select option 1 a function will be called that displays the name and 3 scores for all students in the file, one on each row, no matter how many students are in the file.
if you select option 2 you call a function that allows the user to enter a name and 3 integer scores, and these values are to be added to the dictionary using the name as a key and the value a list of 3 scores.
If you select option 3 your function should print each student's name and the average of the scores for that student. For this option it is not necessary to display the scores themselves, although you can if you want. But the name and averages for sure.
if you select option 4 your function takes each dictionary item and converts it back to string record form, each field separate by a comma, and stored back to the file in the same format that it was originally stored in. This means using a comma separator and each record stored in a separate line. Putting the records back the way you found them means the program can be run a second time without an error.
In addition to the main() function and the function you call to read the data from the file, you will need 4 axillary functions, one function for each of the menu options. Also you must use a dictionary as described above to hold the data while it is in your program.
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