We have a text data file with 9 records. Each record has a name, a midterm score, and a final exam score. The NoGlobr Varables 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. adams 98 86 baker 92 85 carrol 59 89 ... and so on... .. he data file you will need is given in this link: cit101.txt Clicking the link probably opens the file in your browser; save it omewhere where you can find it. The name should remain cit101.txt. When I test your program it should be able to read my ata file, and it will if your data file is named cit101.txt. here are example programs similar to this assignment given in the lecture notes discussing dictionaries. se the python CSV module's csv.DictReader() approach to read the data from the file. Read the tab-separated file into a list of ictionaries when opening the file for reading, and use that list of dictionaries as the program runs. Before exiting, store the ata back to the file using the cvs.DictWriter() so it ends up in the same tab-separated format just like the file you read. he assignment will use a menu-driven model we have often used where each option is selected by entering an integer. An nage of the options you need to offer your program's user is given below. Your menu need not look identical, but should be ery similar to the following. Menu options. 1. Display all student data 2. Calculate a Student's Exam Average 3. Add a Student 4. Save and exit Choose 1, 2, 3, or 4 Enter your choice, 1, 2, 3, or 4:
We have a text data file with 9 records. Each record has a name, a m i d t e r m score, and a f i n a l e x a m 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.
adams 98 86 baker 92 85 carrol 59 89 ... ... ... and so on...The data file you will need is given in this link: cit101.txt (https://bit.ly/3LCQWfD) Clicking 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's csv.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 the cvs.DictWriter() so it ends up in the same tab-separated format just like the file you read.
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 m i d t e r m and f i n a l e x a m 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
Trending now
This is a popular solution!
Step by step
Solved in 2 steps