We have a text data file with 9 records. Each record has a name, a midterm score, and a final exam score. The items in each row are tab-separated. The first couple of rows look like this. But, as we said, the data file contains 9 records total.
adams9886
baker9285
carrol5989
... ... ... and so on...
The data file you will need is given in this link:cit101.txtClicking the link probably opens the file in your browser; save it somewhere where you can find it. The name should remain cit101.txt. When I test your program it should be able to read my data file, and it will if your data file is named cit101.txt.
There are example programs similar to this assignment given in the lecture notes discussing dictionaries.
Use the python CSV module'scsv.DictReader()approach to read the data from the file. Read the tab-separated file into a list of dictionaries when opening the file for reading, and use that list of dictionaries as the program runs. Before exiting, store the data back to the file using thecvs.DictWriter()so it ends up in the same tab-separated format just like the file you read.
The assignment will use a menu-driven model we have often used where each option is selected by entering an integer. An image of the options you need to offer your program's user is given below. Your menu need not look identical, but should be very similar to the following.
You should have a main function and functions for each of the following tasks:
- a function to display the list of all the data (option 1). You do not have to display the average in this option. But all 4 of the columns should line up neatly and be properly justified
- a function to calculate the average of an individual student's two scores (option 2),
- a function to add a student's last name and their midterm and final exam scores to our list of students (option 3).
- a function to store that data back to the file (option 4) in the tab-separated format, using csv.DictWriter() as you exit
- you may or my not need a function to read the data from the file. do use the csv.DictReader() library
For option 2 you should be able to enter a name, like baker, and have the average of student baker's 2 scores be displayed.
For option 3 you should be able to enter a new name and two scores, and have that new record be properly saved to the data file on option 4.
A user of your program should be able to interact with the program as much as they want before deciding to save an exit.
I recommend making a backup copy of the data file in case it gets corrupted. Please start this program early.
As always, let me know if you have questions.
How To Submit Your Program
Attach a zipped folder of your code to an email and send it to me when finished or if you have questions.
Thanks...