Question: Python 3 Coding assignment: Part A: Input names and three test scores of students from the user, terminated by ZZZ and create a data file
Python 3 Coding assignment:
Part A:
Input names and three test scores of students from the user, terminated by "ZZZ" and create a data file "grades.txt" with records of the following form:
student_name (String), test_1 (Integer), test_2 (Integer), test_3 (Integer)
Note: the terminating student name (ZZZ) should not appear in the data file.
See the sample text file below to see how the data should look if you open the file with a text editor.
Part B:
Read and Display the contents of the file "grades" created in Part a. Each students record should appear on a separate line and include the total score (the sum of the three tests) for that student.
See the sample python interaction to see how the data should look at output.
Create functions that will work with the following main(). That is, your main() should contain the following code:
# function to execute the application def main(): # set the working file name fn = "grades.txt" # set the number of scores scores = 3 # get student names and scores, persisting them into a file getStudentData(fn, scores) # obtain the student data from the file lines = getTextFileContents(fn) # print the file contents in report format printReport(lines)
Sample output should look like this (Names and numbers being user input):
Enter the student names and scores following the prompts below. To finish entering student names, enter: ZZZ. Please enter the student name (ZZZ to finish): Dave Enter score 1: 82 Enter score 2: 91 Enter score 3: 77 Please enter the student name (ZZZ to finish): Tom Enter score 1: 79 Enter score 2: 22 Enter score 3: 84 Please enter the student name (ZZZ to finish): Dolly Enter score 1: 67 Enter score 2: 22 Enter score 3: 91 Please enter the student name (ZZZ to finish): ZZZ __________________________________________________________ Student Name Score 1 Score 2 Score 3 Total ---------------------------------------------------------- Dave 82 91 77 250 Tom 79 22 84 185 Dolly 67 22 91 180 __________________________________________________________ Mon Feb 8 15:12:08 2016
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
