Question: he file format inindex.txtis an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the scores column
he file format inindex.txtis an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the scores column consists of "bar" (i.e.,|) separated scores. Furthermore, some scores in that column are missing.
Write some code that reads in the filegrades.txtand calculates the total of the scores that are present. Any missing scores should be treated as having the value zero. So, for example, if the score column is10||20|30then the total should be 60.
Your code should print out the results for each line ingrades.txton its own line in the formName:Total, whereNameis the name in the first column andTotalis the integer sum of the scores.

The file format in index. txt is an unusual one. It has three fields --- name, scores, and ID --- that are comma separated but the scores column consists of "bar" (i.e., | ) separated scores. Furthermore, some scores in that column are missing. Write some code that reads in the file grades. txt and calculates the total of the scores that are present. Any missing scores should be treated as having the value zero. So, for example, if the score column is 10 | |20 |30 then the total should be 60. Your code should print out the results for each line in grades. txt on its own line in the form Name: Total , where Name is the name in the first column and Total is the integer sum of the scores. Input files Contents of grades . txt 1 Mark, 20 25 15 40, u4466898 2 Sue , 45 12 30 15, u1234567 3 Jane, 50 30 35 , u3425174 4 Bob , 20 20 20 , u48539482 A Reset Your code 1 # TODO: Implement your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
